datingissimple com Validating radio buttons using javascript

where the first argument is either a collection of radio buttons, or the name of the button group.

The second argument is a reference to the containing form, though its only necessary if a string is used for the first argument.

And I know my HTML isn't valid, but unless it directly affects my current problem then I'll handle it later.

validating radio buttons using javascript-28

Given a reference, form, you could check the group with either of the following expressions.The setup and validation of radio buttons appears to be the form field that gives many webmasters the most difficulty in setting up.In addition to the Javascript solutions above, you can also use an HTML 5 solution by marking the radio buttons as required in the markup.This will eliminate the need for any Javascript and let the browser do the work for you.Check the method used in the above code By simply putting the JS code to perform the validation will do the validation.

There is a on Submit event that will be invoked when you press a submit button, call the validating code (keep that as a function) so that it will be invoked just before passing the data from the client to the server.

when submit button is pressed and no radio buttons have been selected, it alerts the user saying 'please select a check box', and if a radio button has been selected then simply submit the form, needs no alert.

Can only use HTML CSS and Java Script for this, I know it's 1000 times easier in jquery but sadly I can't use that.

There browsers, however, are often not smart enough to recognize the nesting, so it is worth putting them in to maximize the number of browsers in which the code will function.

That completes the coding of the radio buttons themselves.

To validate the radio button group with the name group1 we therefore pass form.group1 to the val Button function.