bemara57
asked on
How do I validate form values without even submitting?
I'm trying to create checkpoints in my form. So when they click an image in the middle of the form, a new input will be visible. How do I make an onclick event on that image to validate a current selected option on the form, without submitting the form at all? Thanks for the help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually if you need help with that type of validation I can help with that too. Experts on this site are a great resource. However since you said that you wanted to validate WITHOUT submitting then I didn't mention the onsubmit event or other options. Let me know if I misunderstood.
bol
bol
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<form onsubmit="validate()"> ... </form>
And have the validate() function return the right values. Returning 'false' should stop the submitting process, and 'true' will make it continue.
(Modifying b0lsc0tt's code here)
function validate() {
if (document.getElementById("
alert("Please enter something for option1."); return false;
}
// put more if checks here if necessary.
return true;
}
Go to your favorite search angine and search for Javascript Form Validation, there should be many more resources available for you.