I want the javascript to test an alphanumeric (a string contains
alphabet or numbers only) string. Should I write a regular expression?
What's the best way to do? please help. thanks
From my validation.js file...
function checkAlphanum(strObject)
{
/* Returns true if the field has all alphanumeric characters, false if
not.
You must pass in a input (text) object, not the value. */
var re = /^[A-Za-z0-9]+$/;
if (!strObject || isBlank(strObject)) return false;
else return re.test(strObject.value);
}
function isBlank(strObject)
{
/* Returns true if the field is blank, false if not.
You must pass in an input (text) object (not the value) */
var re = /\S+/;
if (!strObject) return true;
return re.test(strObject.value));
}
HTH
--
--
~kaeli~
If that phone was up your a$$, maybe you could drive a
little better!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace