radio button validation

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
qumar
Forum Commoner
Posts: 29
Joined: Wed Nov 01, 2006 8:20 am

radio button validation

Post 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]
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

It's more secure to do validation server-side.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply