Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Validation 1

Status
Not open for further replies.

MikeT

IS-IT--Management
Feb 1, 2001
376
US
I have two text boxes in a form. When the user clicks Submit, I want to make sure both of those fields contain values. If they don't, I want an alert to pop up.

Should be simple......right?
 
Simple validation concept below:

<script>

function validate(frm)
{
var boo=true;
if(frm.name.value==&quot;&quot;)
{
boo=false;
alert(&quot;Please enter a name.&quot;);
}
if(frm.age.value==&quot;&quot;)
{
boo=false;
alert(&quot;Please enter an age.&quot;);
}
return boo;
}

</script>

<form onsubmit=&quot;return validate(this)&quot;>

<input type=&quot;text&quot; name=&quot;name&quot;>
<input type=&quot;text&quot; name=&quot;age&quot;>

</form> jaredn@eae.net -
 
here's a FAQ on the subject

only where they talk about asking if a radio button is .checked, you will ask to see whether or not the .value == &quot;&quot;

good luck! :)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top