Validating checkbox using javascript


A reference to the whole form was passed as a parameter into the function, which uses the "form" argument to refer to the complete form.To validate the radio button group with the name group1 we therefore pass form.group1 to the val Button function.The setup and validation of radio buttons appears to be the form field that gives many webmasters the most difficulty in setting up.In actual fact the setup of these fields is the most simple of all form fields to validate as radio buttons set one value that only needs to be tested when the form is submitted.



The value that will be passed for a specific group when the form is submitted will be the value of the button within the group that is selected at the time that the form is submitted.I am not sure why you have the Try/Catch statements in the validation. The second problem you had is the check that validated the phone number boxes returned true if the validation passed.The following is sufficient (at least when looking at the code you posted). First you still had the OR statement in the javascript area that checked to see if someone had put either their telephone or cellphone number. The problem with this is you never let the javascript get to the validation for the check box.to test the form i have used Javascript that just validats that at least one checkbox is checked now this should return to the form when validated and the form action should then pass the user to the correct page, this doesnt happen, the javascript seems to be validating correctly gives an alert if the validation fails but just returns to the form if it validates, the form action does not pass the user to the correct page.

You know I spent about a half hour (maybe longer) trying to figure out what you were doing wrong.

You only need one return, and that return should be after the check box.