ash.h
04-24-2008, 10:14 AM
hi guys how you are ?hope u doin good.
as i said i am new at js and i don't now how to creat a code that control the textbox so it accepts only english alphabits
i made a code but i didn't work well .
it just check the first index .
please help me with this .
here it is :
<script language="javascript">
function checked()
{
var str =new String();
var m;
var x;
str=f1.t1.value;
for(var i=0 ;i<=str.length ;i++)
{
m=str.charCodeAt(i);
if(m>=97 && m<=122)
x=1;
else{
x=0;
break;
}
}
if (x==1)
return true;
else
alert("the input value is only english");
return false;
}
</script>
<form name="f1" action="" Onsubmit="return checked()">
<input type="text" name="t1">
<input type="submit">
as i said i am new at js and i don't now how to creat a code that control the textbox so it accepts only english alphabits
i made a code but i didn't work well .
it just check the first index .
please help me with this .
here it is :
<script language="javascript">
function checked()
{
var str =new String();
var m;
var x;
str=f1.t1.value;
for(var i=0 ;i<=str.length ;i++)
{
m=str.charCodeAt(i);
if(m>=97 && m<=122)
x=1;
else{
x=0;
break;
}
}
if (x==1)
return true;
else
alert("the input value is only english");
return false;
}
</script>
<form name="f1" action="" Onsubmit="return checked()">
<input type="text" name="t1">
<input type="submit">