hi,
i m new to this site as well as to Javascript.In my project i need to use javascript..in my code if i enter the textfield 'MA' it should take along with numbers...but the problem is if i enter 'MAA' it is not showing any error..the text field should take on 'MA' not 'MAA'...i used the charAt() function...i m not getting any one can help me...its urgent...here i m sending the code..waiting for the reply...
Thanks&Regards,
madhuri.
i m new to this site as well as to Javascript.In my project i need to use javascript..in my code if i enter the textfield 'MA' it should take along with numbers...but the problem is if i enter 'MAA' it is not showing any error..the text field should take on 'MA' not 'MAA'...i used the charAt() function...i m not getting any one can help me...its urgent...here i m sending the code..waiting for the reply...
Code:
function pasuser(form)
{
if (form.n1.value == "")
{
alert("Enter Package Name");
form.n1.focus();
return (false);
}
var chk = form.n1.value;
var chk1=chk.charAt(0);
var allValid = true;
if (chk1=="M")
{
alert("u entered correct");
form.n1.focus();
allValid = false;
}
else if (!allValid)
{
alert("Enter only M");
form.n1.focus();
return (false);
}
form.submit();
return true;
}
madhuri.
Comment