Page 1 of 1

radio button validation

Posted: Mon Oct 15, 2007 9:00 am
by qumar
pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi,
how to validate the radio button using javascript. i tried with following script but not getting. please help to me.

[syntax="php"]
<script language='javascript'>

function checkscript()
{
	
	if (document.contact_form.gender.checked=='')    
    {
        alert('Please choose your Gender: Male or Female');
		//document.contact_form.gender.focus()
        return false;
    }
	return true;
}	

</script>
<?php
<form name='contact_form' method='post' action='' onsubmit='return checkscript()'>

Select Geneder:<input type='radio' name='gender' value='Male'>Male<input type='radio' name='gender' value='FeMale'>FeMale
<input type='submit' name='submit' value='Submit'>
</form>

?>
thanks,
qumar.


pickle | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Oct 15, 2007 9:29 am
by superdezign
It's more secure to do validation server-side.

Posted: Mon Oct 15, 2007 10:20 am
by pickle
Javascript is NOT the same as PHP & it's run client-side :roll: . Please make sure you post your questions in the right forum. I've moved this thread to Client Side.