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

string.length

Status
Not open for further replies.

wsmall73

Programmer
May 23, 2002
261
US
I am trying to write a custom validator using javascript and I am simply trying to determine the length of what should be a string...

function ClientValidate(source,args)
{

alert(""+args.Value.Length);
args.IsValid=true;
}

I added the ""+ to try to ensure that it was forced to a string but I am obviously missing something.. any assistance would be greatly appreciated. TIA
 
The correct syntax for checking form field length is document.formfieldname.value.length. (Note that value and length are lower case.) Without knowing what source and args are, and how you're passing them to your function, it's a little difficult give you a firm answer.

There's always a better way. The fun is trying to find it!
 
The correct syntax for checking form field length is document.formfieldname.value.length

Maybe if you want your code to function in IE only... This would be a much more correct way of doing things:

Code:
document.forms['formName'].elements['formFieldName'].value.length

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top