![]() |
i am new at js and i need help so bad
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"> |
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?
Code:
function checked(){ |
thanks alooooooots
i know it's enough but it is the only way to thank you sir i reformed like this function checked(){ [abcdefghijklme...ABCDEF.....].test(f1.t1.value); } 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]+$/ |
It is a regular expression and you post should have been in the main section since it has nothing to do with frameworks.
Eric |
| All times are GMT +1. The time now is 03:17 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.