Gossamer Forum
Home : General : Internet Technologies :

Javascript deny certain characters

Quote Reply
Javascript deny certain characters
Here's the scoop. I want a field to only allow the characters A-Za-z0-9. I also only one lower case text, so I am converting it on the fly as well. Here is what I have:


var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
function res(t,v){
var w = "";
for (i=0; i < t.value.length; i++) {
x = t.value.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
t.value = w;
t.value = t.value.toLowerCase();

and I call this function like this:



It works really well ... except (you knew there would be an "except") ..

it allows the extended character set. You can hold the alt key and enter a extended character set code and it will accept the entry. How can I also exclude the extended characters?
Quote Reply
Re: [Lee] Javascript deny certain characters In reply to
See if you can hack one out of http://javascript.internet.com

Look in "Forms"