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!

yet another form validation question. 3

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
US
Background - I'm a novice programmer, have some experience with VB, VBA, and VBScript.

JavaScript is new to me. SO..... I'm trying to do the following pseudocode:

if (document.frmComments.ContactZipCode.LENGTH OF USER'S INPUT <5 OR IF IT'S GREATER THAN 10 DIGITS)
{
alert (&quot;Please double check your zip code entry.&quot;)
return false;
document.frmComments.ContactZip.focus
}

Side notes (may or may not matter):

ContactZipCode is just a text box on a form, defined as:

Zip: <INPUT NAME=&quot;AgencyZip&quot; TYPE=&quot;TEXT&quot; SIZE=&quot;10&quot; ALIGN=&quot;left&quot;><P>

I tried this code, but &quot;length&quot; is not a recognized property, and &quot;value&quot; doesn't seem to give me what I need

else if (document.frmComments.ContactZip.length <5)
{
alert (&quot;Please double check your zip code entry.&quot;)
return false;
document.frmComments.ContactZip.focus
}

Any help is sincerely appreciated. I ask lots of questions, but I take care to be clear, and always post back results and resolutions so they can help others.
 
scroce,

Just a slight adjustment:

else if (document.frmComments.ContactZip.value.length <5)
{
alert (&quot;Please double check your zip code entry.&quot;)
return false;
document.frmComments.ContactZip.focus()
}

Mise Le Meas,

Mighty :)
 
thank you. that was exactly it. I knew I was close. It's little things like that which can drive you crazy. I ask lots of questions, but I take care to be clear, and always post back results and resolutions so they can help others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top