Javascript validating input

posted by | Leave a comment

Validating form input with Java Script is easy to do and can save a lot of unnecessary calls to the server as all processing is handled by the web browser.

The illustration below shows this relationship: Note that the 'I' in selected Index needs to be capitalised - Java Script functions and variables are always case-sensitive. Read more about the humble checkbox in our HTML5 Checkbox Validation article.

Radio buttons are implemented as if they were an array of checkboxes.

To find out which value (if any) has been selected, you need to loop through the array until you find which one has been selected: In the case of a single radio button we have nothing to loop through so just return either it's value, if the radio button is checked, or false.

I've coded a working form, all checks are great but for some reason the hardest part is trying to stop form submission before validation.

So i have places to insert the stop validation code, but just cant find any that works.

Leave a Reply

Free adult dating profiles without registering