Interesting.But why so

This works

if(!f.mobNo.length=10)
{ alert(“you must provide a MObile no with 10 digits only.”);
return false;

	}

This doesn’t works

if(f.mobNo.length!=10)
{ alert(“you must provide a MObile no with 10 digits only.”);
return false;

	}

Any ideas ??

First of all sorry about my english.

The first comparation are wrong, you must compare with “==”

if(!f.mobNo.length==10)
{
alert(“you must provide a MObile no with 10 digits only.”);
return false;

}

And this incorrect, you should write “f.mobNo.value.length”, because withing value you are checking the length of mobNo , is it’s not array will be always 1. You will check the length of value.

after all, you must use document.f.mobNo or the DOM tree that you have, but if you use only the name doesn’t works on some explorer (Firefox,chrome,etc)
You can use document.getElementById instead.

Hmm…I got it .
thanx .

Sponsor our Newsletter | Privacy Policy | Terms of Service