PDA

View Full Version : texteBox Typed


angiras
04-26-2003, 12:30 PM
I have found here this very good script :

var lettres="abcdefghijklmnopqrstuvwxyzABCDEFRHIJKLMNOPQRSTUVWXYZ";
var nombres="1234567890";
var nombresPoint="1234567890.";


function alpha(e,allow)
{
var k;
k=document.all?parseInt(e.keyCode): parseInt(e.which);
return (allow.indexOf(String.fromCharCode(k))!=-1);
}




I call it

<input type="text" id="nb" onkeypress="return alpha(event,nombres)"/>


how can I use regular expression with it
email adress or any ?

thank you

boywonder
04-26-2003, 04:52 PM
Not to single you out or anything, but I am vehemently opposed to this kind of "disabling" of a user's keyboard. It is the exact opposite of user-friendliness if you ask me.

Did you know that in Mozilla (I assume Netscape also) that script also has the effect of "disabling" the text box navigation keys such as home, end, backspace, delete, and the arrow keys? There are much better ways to validate user input.

As far as validating an e-mail address with regular expressions, there have been some lengthy threads on that topic here. Maybe these will help you http://www.codingforums.com/search.php?s=&action=showresults&searchid=113651&sortby=&sortorder=


(edit was for corrected link)

angiras
04-26-2003, 07:34 PM
thank you for the link

angiras
04-28-2003, 07:40 AM
I have not found what I am looking for

<input type="text" id="tb0" onkeypress="validate(format)" />


format must be a variable = regular Expression

I am looking for a script where you can add as many regular expression as needed

to validate text Boxes

thanks

Skyzyx
04-28-2003, 04:30 PM
Check out beetle's fValidate at http://www.peterbailey.net/fValidate/

angiras
04-28-2003, 05:34 PM
thanks I know this one but I find it so heavy :-((

thanks anyway