Validate A Form With Javascript Before Submitting With Ajax?
I've been making a website and I want a nice login/registration/forgot pass form. I wanted to use 'ajax' to make it nice for the user and, consequently, have spent the last 2 weeks
Solution 1:
<form id="loginFormID" onsubmit="return validateLoginFormOnSubmit();" method="post" autocomplete="on">
JavaScript
funciton validateLoginFormOnSubmit() {
//do client side validation
if(true == validation) {
//do the `ajax` call with serialized form data
}
else {
//show error
}
return false; // because we want to submit only through `ajax`, so stopping original form submit.
}
Post a Comment for "Validate A Form With Javascript Before Submitting With Ajax?"