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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to be able to have two restrictions on a value.length

Status
Not open for further replies.

CHRISWYA

IS-IT--Management
Sep 14, 2004
19
GB
I'm sure there must be an easy way around this problem but am currently struggling to fing the required solution.

Currently i am using the syntax for javascript validation before submitting the form to enure my text area has <5 characters which is fine.

if (theForm.textname.value.length <5)
Then...

however it is also possible the text value could be null which is causing me the problem therefore i am looking for a solution along these lines

if (theForm.textname.value.length >1 <5)
Then...

any suggestions!!
 
if ((theForm.textname.value.length >1) && (theForm.textname.value.length <5))
 
or:
if (!theForm.textname.value.match(/^.{1,5}$/))
{
alert("Greater than 1 and less that 5.")
}

Known is handfull, Unknown is worldfull
 
cheers for the help lads
much appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top