Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Removing unwanted characters

Reply
Thread Tools

Removing unwanted characters

 
 
Phil Amey
Guest
Posts: n/a
 
      01-13-2004
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



 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      01-13-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing unwanted registry entries? PMcOuntry Computer Support 1 07-06-2006 07:23 PM
Removing Unwanted Windblows Updates Sens Fan Happy In OH Computer Support 5 05-31-2006 11:00 AM
Removing unwanted network place =?Utf-8?B?TGFycnk=?= Wireless Networking 0 05-30-2006 06:55 PM
Removing unwanted toolbars Maxi Javascript 5 04-06-2006 01:55 AM
thunderbird: removing unwanted posts NewB Computer Support 4 02-13-2005 09:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57