Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Javascript Validation


Message #1 by jstmehr4u3@a... on Tue, 12 Mar 2002 20:57:46 +0000
Here is my Validation Function (JavaScript) and my form 

code(HTML). I am trying to validate wether or not the 

user click the NO radio Button, and obviously, its not 

working. Help?





<script Language="JavaScript">

<!--

function HELPMe(theForm)

{

	if (theForm.Accept.value <> "3")

	{

		alert("Please select YES to coninue.");

		theForm.Accept.focus();

		return (false);

	}

	if (theForm.test.value == "")

	{

		alert("Oh Sure");

		theForm.test.focus();

		return (false);

	}

return (true);

}

//-->

</script>

<form action="test.asp" method="post" onsubmit="return 

HELPMe(this)">

no<input type="radio" name="Accept" value="0" checked>

yes<input type="radio" name="Accept" value="1">

text<input type="text" name="test">

<input type="submit">

</form>





TIA!

Mike S.

Message #2 by "Debreceni, David" <Debreceni.David@h...> on Tue, 12 Mar 2002 16:04:11 -0500
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C1CA09.753D42B0

Content-Type: text/plain;

	charset="iso-8859-1"



Radio buttons named like that are treated as an array

try something like

if (theForm.Accept[1].value == "1")



hope that helps



Dave 

-----Original Message-----

From: jstmehr4u3@a... [mailto:jstmehr4u3@a...]

Sent: Tuesday, March 12, 2002 3:58 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Javascript Validation





Here is my Validation Function (JavaScript) and my form 

code(HTML). I am trying to validate wether or not the 

user click the NO radio Button, and obviously, its not 

working. Help?





<script Language="JavaScript">

<!--

function HELPMe(theForm)

{

	if (theForm.Accept.value <> "3")

	{

		alert("Please select YES to coninue.");

		theForm.Accept.focus();

		return (false);

	}

	if (theForm.test.value == "")

	{

		alert("Oh Sure");

		theForm.test.focus();

		return (false);

	}

return (true);

}

//-->

</script>

<form action="test.asp" method="post" onsubmit="return 

HELPMe(this)">

no<input type="radio" name="Accept" value="0" checked>

yes<input type="radio" name="Accept" value="1">

text<input type="text" name="test">

<input type="submit">

</form>





TIA!

Mike S.






$subst('Email.Unsub').




Message #3 by jstmehr4u3@a... on Tue, 12 Mar 2002 21:36:09 +0000
Thanks. But now all it does is alert me. It does not 

distinguish between the two seperate values. If I click 

YES, it tells me to click YES. If I click NO it tells me 

to click YES.





Mike

> Radio buttons named like that are treated as an array

> try something like

> if (theForm.Accept[1].value == "1")

> 

> hope that helps

> 

> Dave 

> -----Original Message-----

> From: jstmehr4u3@a... [mailto:jstmehr4u3@a...]

> Sent: Tuesday, March 12, 2002 3:58 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Javascript Validation

> 

> 

> Here is my Validation Function (JavaScript) and my form 

> code(HTML). I am trying to validate wether or not the 

> user click the NO radio Button, and obviously, its not 

> working. Help?

> 

> 

> <script Language="JavaScript">

> <!--

> function HELPMe(theForm)

> {

> 	if (theForm.Accept.value <> "3")

> 	{

> 		alert("Please select YES to coninue.");

> 		theForm.Accept.focus();

> 		return (false);

> 	}

> 	if (theForm.test.value == "")

> 	{

> 		alert("Oh Sure");

> 		theForm.test.focus();

> 		return (false);

> 	}

> return (true);

> }

> //-->

> </script>

> <form action="test.asp" method="post" onsubmit="return 

> HELPMe(this)">

> no<input type="radio" name="Accept" value="0" checked>

> yes<input type="radio" name="Accept" value="1">

> text<input type="text" name="test">

> <input type="submit">

> </form>

> 

> 

> TIA!

> Mike S.

> 




> $subst('Email.Unsub').

> 

> 




Message #4 by "Debreceni, David" <Debreceni.David@h...> on Tue, 12 Mar 2002 16:41:16 -0500
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C1CA0E.A3A7CA80

Content-Type: text/plain;

	charset="iso-8859-1"





Sorry bout that, try



if (theForm.Accept[1].checked == 0)

I think that works.



Dave



-----Original Message-----

From: jstmehr4u3@a... [mailto:jstmehr4u3@a...]

Sent: Tuesday, March 12, 2002 4:36 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Javascript Validation





Thanks. But now all it does is alert me. It does not 

distinguish between the two seperate values. If I click 

YES, it tells me to click YES. If I click NO it tells me 

to click YES.





Mike

> Radio buttons named like that are treated as an array

> try something like

> if (theForm.Accept[1].value == "1")

> 

> hope that helps

> 

> Dave 

> -----Original Message-----

> From: jstmehr4u3@a... [mailto:jstmehr4u3@a...]

> Sent: Tuesday, March 12, 2002 3:58 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Javascript Validation

> 

> 

> Here is my Validation Function (JavaScript) and my form 

> code(HTML). I am trying to validate wether or not the 

> user click the NO radio Button, and obviously, its not 

> working. Help?

> 

> 

> <script Language="JavaScript">

> <!--

> function HELPMe(theForm)

> {

> 	if (theForm.Accept.value <> "3")

> 	{

> 		alert("Please select YES to coninue.");

> 		theForm.Accept.focus();

> 		return (false);

> 	}

> 	if (theForm.test.value == "")

> 	{

> 		alert("Oh Sure");

> 		theForm.test.focus();

> 		return (false);

> 	}

> return (true);

> }

> //-->

> </script>

> <form action="test.asp" method="post" onsubmit="return 

> HELPMe(this)">

> no<input type="radio" name="Accept" value="0" checked>

> yes<input type="radio" name="Accept" value="1">

> text<input type="text" name="test">

> <input type="submit">

> </form>

> 

> 

> TIA!

> Mike S.

> 




> $subst('Email.Unsub').

> 

> 




$subst('Email.Unsub').






$subst('Email.Unsub').




Message #5 by jstmehr4u3@a... on Tue, 12 Mar 2002 21:52:26 +0000
Thanks! It worked!

> 

> Sorry bout that, try

> 

> if (theForm.Accept[1].checked == 0)

> I think that works.

> 

> Dave

> 

> -----Original Message-----

> From: jstmehr4u3@a... [mailto:jstmehr4u3@a...]

> Sent: Tuesday, March 12, 2002 4:36 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] RE: Javascript Validation

> 

> 

> Thanks. But now all it does is alert me. It does not 

> distinguish between the two seperate values. If I click 

> YES, it tells me to click YES. If I click NO it tells me 

> to click YES.

> 

> 

> Mike

> > Radio buttons named like that are treated as an array

> > try something like

> > if (theForm.Accept[1].value == "1")

> > 

> > hope that helps

> > 

> > Dave 

> > -----Original Message-----

> > From: jstmehr4u3@a... [mailto:jstmehr4u3@a...]

> > Sent: Tuesday, March 12, 2002 3:58 PM

> > To: ASP Web HowTo

> > Subject: [asp_web_howto] Javascript Validation

> > 

> > 

> > Here is my Validation Function (JavaScript) and my form 

> > code(HTML). I am trying to validate wether or not the 

> > user click the NO radio Button, and obviously, its not 

> > working. Help?

> > 

> > 

> > <script Language="JavaScript">

> > <!--

> > function HELPMe(theForm)

> > {

> > 	if (theForm.Accept.value <> "3")

> > 	{

> > 		alert("Please select YES to coninue.");

> > 		theForm.Accept.focus();

> > 		return (false);

> > 	}

> > 	if (theForm.test.value == "")

> > 	{

> > 		alert("Oh Sure");

> > 		theForm.test.focus();

> > 		return (false);

> > 	}

> > return (true);

> > }

> > //-->

> > </script>

> > <form action="test.asp" method="post" onsubmit="return 

> > HELPMe(this)">

> > no<input type="radio" name="Accept" value="0" checked>

> > yes<input type="radio" name="Accept" value="1">

> > text<input type="text" name="test">

> > <input type="submit">

> > </form>

> > 

> > 

> > TIA!

> > Mike S.

> > 




> > $subst('Email.Unsub').

> > 

> > 




> $subst('Email.Unsub').

> 




> $subst('Email.Unsub').

> 

> 




Message #6 by "Drew, Ron" <RDrew@B...> on Wed, 13 Mar 2002 09:24:38 -0500
<script Language=3D"JavaScript">

<!--

function HELPMe() {

 if(document.test.Accept[0].checked=3D=3Dtrue){

	Alert("Please select YES to coninue");

      document.test.Accept.focus();

	return (false);

	}

	if (document.test.value =3D=3D "")

	{

		alert("Oh Sure");

		document.test.focus();

		return (false);

	}

return (true);

}

//-->

</script>

<form action=3D"test.asp" name=3D"test" method=3D"post" 

onsubmit=3D"return

HELPMe()">

no<input type=3D"radio" name=3D"Accept" value=3D"0" checked>

yes<input type=3D"radio" name=3D"Accept" value=3D"1">

text<input type=3D"text" name=3D"test">

<input type=3D"submit" VALUE=3D"Send">

</form>







-----Original Message-----

From: jstmehr4u3@a... [mailto:jstmehr4u3@a...]

Sent: Tuesday, March 12, 2002 3:58 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Javascript Validation





Here is my Validation Function (JavaScript) and my form

code(HTML). I am trying to validate wether or not the

user click the NO radio Button, and obviously, its not

working. Help?





<script Language=3D"JavaScript">

<!--

function HELPMe(theForm)

{

	if (theForm.Accept.value <> "3")

	{

		alert("Please select YES to coninue.");

		theForm.Accept.focus();

		return (false);

	}

	if (theForm.test.value =3D=3D "")

	{

		alert("Oh Sure");

		theForm.test.focus();

		return (false);

	}

return (true);

}

//-->

</script>

<form action=3D"test.asp" method=3D"post" onsubmit=3D"return

HELPMe(this)">

no<input type=3D"radio" name=3D"Accept" value=3D"0" checked> yes<input

type=3D"radio" name=3D"Accept" value=3D"1"> text<input type=3D"text"

name=3D"test"> <input type=3D"submit"> </form>





TIA!

Mike S.






$subst('Email.Unsub').


  Return to Index