In article <>,
enlightened us with...
> In a web based form I am able to make sure that there is text in an input field but I want to restrict the user from using such characters as ~
> # & '
>
> How can I modify this JavaScript below to enable this ?
>
> if (document.form1.ProjectTitle.value == ""){
> alert("Please complete the Project Title: field")
> document.form1.ProjectTitle.focus()
> validFlag = false
> return validFlag
> }
>
> When entering the project title into another system it issues an error when those characters are input - hence the need to delete them from the
> request
>
> Kindest Regards - Philip Amey
>
>
>
>
Here's my function. Modify it to include the characters you like.
Characters listed in the variable "re" are ALLOWED.
function checkAlphanumSpecial(strObject)
{
/* Returns true if the field has all alphanumeric characters and some
special chars,
plus whitespace, 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;
if (!re.test(strObject.value)) return false;
else return true;
}
if (!checkAlphanumSpecial(document.form1.ProjectTitle )){
--
--
~kaeli~
Once you've seen one shopping center, you've seen a mall.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace