Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reject special characters from user input

Status
Not open for further replies.

Albuckj2

Programmer
Jan 7, 2003
68
GB
When users input something into a prompt box, how can I stop users entering special characters?
i.e. - I only want to allow characters and numbers

Thanks,
Alex.
 

Here is a sample.

<Html>
<head><title></title>
</head>
<BODY>


<center>
<form>
This field will not accept special characters: (like !@#$%^&* etc)<br>
<textarea rows=2 cols=20 name=comments onKeypress=&quot;if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)) event.returnValue = false;&quot;></textarea>
<br>
</form>
</center>
</Body>
</Html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top