Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: SV: Re: SV: checking for nonalpha numeric characters


Message #1 by "Robert Nyman" <robert.nyman@c...> on Mon, 13 Jan 2003 16:14:19 +0100
Excellent! thanx a million - where can i find these regular expression
i would like the check to check for non alpha numerics

so it would be something like

> function keyCheck(e){
	var keyChar = String.fromCharCode(e.which);
	if((keyChar.search(/\D/) != -1) && (keyChar.search(alpha reg expr)!
= -1){
		alert(One of the characters isn't alpha numeric");
	}
}

thanx a million
Noreen



> The 3D is just a mess-up in WROX mailing lists.
Just remove all instances of 3D.

The RegExp is looking for anything that isn't a digit.
If it finds anything the alert pops up.


/Robert


-----Ursprungligt meddelande-----
Fr=E5n: Noreen M Masterson [mailto:noreen_masterson@s...]=20
Skickat: den 13 januari 2003 15:24
Till: JavaScript HowTo
=C4mne: [javascript_howto] Re: SV: checking for nonalpha numeric
characters


hi robert

confused by 3D string? - is this just a var instance or?
also the reg expr u search for /\D what does this equate to?

thanx
noreen

> function keyCheck(e){
	var keyChar =3D3D String.fromCharCode(e.which);
	if(keyChar.search(/\D/) !=3D3D -1){
		alert(One of the characters isn't a number");
	}
}


/Robert


-----Ursprungligt meddelande-----
Fr=3DE5n: Noreen M Masterson =
[mailto:noreen_masterson@s...]=3D20
Skickat: den 13 januari 2003 15:09
Till: JavaScript HowTo
=3DC4mne: [javascript_howto] checking for nonalpha numeric characters


hi

i am trying to check each character entered and make sure it is only
an=3D20 alpha-numeric char

function keyCheck(e){
	var keyChar =3D3D String.fromCharCode(e.which);
	//here is where u would have to check the key then
}

document.captureEvents(Event.KEYPRESS);
document.onkeypress =3D3D keyCheck;

i know in Java u can use char.isLetterorDigit(myString.charAt(index))

but how can this be done in javascript??

thanx
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D20 to
unsubscribe send a blank email to 


---
Change your mail options at http://p2p.wrox.com/manager.asp or=20
to unsubscribe send a blank email to




  Return to Index