Javascript to check a length

Below javascript is checking for length, if it exceeds over 15 char., it will automatically remove char. after 15. I am using this code for both Notes and Web client as Common Javascript.

I am having trouble in notes client. The message alert eventhough the value is less than 15 character long. Why? Please advise

if(document.forms[0].TargetNumSub.value!==“”)

{

if (TargetNumSub.value.length>15);

alert (“Target Number Of Subjects must not exceed more than Fiftheen characters. Please retype the information.”);

TargetNumSub.value = TargetNumSub.value.substring(0,15);

}

Subject: Javascript to check a length

!==

Subject: RE: Javascript to check a length

I do have !== in my code. I am not understand, please clarify your suggestion.

Subject: RE: Javascript to check a length

Try changing that to

!=

Subject: RE: Javascript to check a length

no luck

Subject: Javascript to check a length

TargetNumSub.value.length is NOT the same thing as document.forms[0].TargetNumSub.value.length. Your code is looking for an object (TargetNumSub) that doesn’t exist.

And !== does not mean “is not equal to”, it means “is not identical to”. It is the “not” version of the identity comparator (===), not of the equivalency comparator (==). Identity means that the objects being compared are the same object, not that they have the same value.

Subject: RE: Javascript to check a length

Please tell me what to do or what code to use.

Subject: re:Javascript to check a length

try this:var obj = document.forms[0].TargetNumSub;

if (obj.value.length>15){

alert (“Target Number Of Subjects must not exceed more than 15 characters. Please retype the information.”);

obj.value = obj.value.substring(0,15);

}

Subject: RE: re:Javascript to check a length

it works.thanks

amp