Camillia
asked on
Checking for length of strings in Javascript
I have 6 fields on a page. User clicks OK and I want to check the length of each field in Javascript and then display on the asp.net page which field needs to be longer...
Any examples ?
Any examples ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, i got the main part done but I have a question. This is what I have:
var txtHPhone = document.getElementById('< %= Page.Master.FindControl("C ontentPlac eHolder1") .FindContr ol("txtHPh one").Clie ntID %>');
....
else if ( txtHPhone.value.length <= 3)
{
document.getElementById('< %= Page.Master.FindControl("C ontentPlac eHolder1") .FindContr ol("lblErr or").Clien tID %>').innerHTML = "<b>Length of your search field must be greater than 3</b>";
}
**** How can I specify the name of the field ? For example : Length of Home Phone field must be greater than 3... ***Note "Home Phone". So how do I get the label name in there?
I tried this but didnt work:
document.getElementById('< %= Page.Master.FindControl("C ontentPlac eHolder1") .FindContr ol("lblHPh one").Clie ntID %>')
var txtHPhone = document.getElementById('<
....
else if ( txtHPhone.value.length <= 3)
{
document.getElementById('<
}
**** How can I specify the name of the field ? For example : Length of Home Phone field must be greater than 3... ***Note "Home Phone". So how do I get the label name in there?
I tried this but didnt work:
document.getElementById('<
ASKER