var hostName = 'http://'+window.location.host; window.addEvent('domready', function() { var myRequest = new Request({ method: 'get', url: '../template/inquiry_sub.php', onComplete: function(response) { $('divInquiry').set('html',response); } }); myRequest.send(); }); var submitForm = function(){ if($('iqName').get('value')=="") { alert("Your name is required!"); return; } if(!isEmail($('iqEmail').get('value'))) { alert("your valid email is required!"); return; } if($('iqContent').get('value')=="") { alert("Please input your inquiry!"); return; } //Prevents the default submit event from loading a new page. $('status').set('value','add'); $('submit_value').set('html','wait...'); //e.stop(); $('formInquiry').set('send', { onRequest:function(){ //$('btnSubmit').set('disabled',true); }, onComplete: function(response) { switch(response){ case '1': alert('you have already added it!'); return; break; case '2': $('status').set('value',''); var arrDivData=['iqName','iqTel','iqEmail']; arrDivData.each(function(item, index){ $(item).set('value',''); }); $('formInquiry').reset(); $('iqContent').set('html',''); alert('Thanks for your inquiry!'); $('submit_value').set('html','submit'); break; default: alert(response); $('submit_value').set('html','submit'); return; break; } //log.removeClass('ajax-loading'); } }); //Send the form. $('formInquiry').send(); }