View Full Version : i am new at js and i need help so bad

04-24-2008, 09: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;
for(var i=0 ;i<=str.length ;i++)
if(m>=97 && m<=122)
if (x==1)
return true;
alert("the input value is only english");
return false;

<form name="f1" action="" Onsubmit="return checked()">
<input type="text" name="t1">
<input type="submit">

04-24-2008, 11:34 AM
Umm... I don't really know what I'm talking about, so hopefully someone will be along shortly to explain in simple terms about unicode and character encoding and internationalisation, but... can't you just do a regexp match?

function checked(){
return /^[\w\s]+$/.test(document.f1.t1.value);

04-26-2008, 08:56 AM
thanks alooooooots
i know it's enough but it is the only way to thank you sir
i reformed like this
function checked(){

and it worked
as i told u that i am still new at this and i never seen a code like urs so could u please expalin the followin /^[\w\s]+$/

04-27-2008, 09:45 PM
It is a regular expression and you post should have been in the main section since it has nothing to do with frameworks.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum