Skip to main content

Posts

Showing posts from February, 2010

Form validations before submitting it

Try to use 'OnSubmit' attribute of the form tag in your page, for submitting the page. We use the action attribute of the form to specify the destination page for the current page. But before submitting, we generally want to validate few fields in the form. And if we use something like: onSubmit="return valid();" , the form submission happens only after the function valid() returns true, and we can perform all validations inside the function. Ex: function valid() { var d = document.form1; if(d.email.value ==""){ alert("Please enter the email"); d.email.focus(); return false; } return true; }