Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: SV: checking for nonalpha numeric characters


Message #1 by "Robert Nyman" <robert.nyman@c...> on Mon, 13 Jan 2003 16:03:44 +0100
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 =3D String.fromCharCode(e.which);
	if(keyChar.search(/\D/) !=3D -1){
		alert(One of the characters isn't a number");
	}
}


/Robert


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


hi

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

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

document.captureEvents(Event.KEYPRESS);
document.onkeypress =3D 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=20
to unsubscribe send a blank email to




  Return to Index