Jump to content

Radio button validation


rms230

Recommended Posts

Here's an example for you, it's about as easy as i can make it.When the radio button is clicked it sends the value to the function, the function checks the data and displays an alert.

<html><head><script>function check(val){if(val=="Blue")alert("Welldone "+val+" is correct");else alert("Sorry "+val+" is incorrect");}</script></head><body><form><p>What color is the sky?</p><input type="radio" name="q1" value="Red" onclick="check(this.value)">Red<input type="radio" name="q1" value="Green" onclick="check(this.value)">Green<input type="radio" name="q1" value="Blue" onclick="check(this.value)">Blue</form></body></html>

Any more questions let me know :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...