When the user does so, they may proceed and can supply value to the next available field.The later Java Script function created is called on the onsubmit event of the form. If Male or Female is selected, it generates an alert saying that the form is successfully submitted and it reloads the form.Flowchart : Download the Validation code from here.The reason your current code doesn't work is because you don't have a FORM tag in there.Using client side Java Script is an efficient way to validate the user input in web forms.
No need to write even a single Java Script line for simple form validation.
In this document, we have discussed Java Script Form Validation using a sample registration form.
The tutorial explores Java Script validation on submit with detail explanation.
View example » Parsley is shipped with more than a dozen useful validators.
If not enough, use the awesome Parsley extra Ajax validator or tons of other extended validators provided by the community.
Also, lookup using "name" is not recommended as its deprecated.