473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Removing unwanted characters

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

Jul 20 '05 #1
1 3791
In article <40***************@btinternet.com>, ph******@btinternet.com
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

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Peter O'Reilly | last post by:
I have an HTML form with a textarea input box. When the user conducts a post request (e.g. clicks the submit button), an HTML preview page is presented to them with the information they have...
7
by: Frank.Sebesta | last post by:
I have a wedge mag stripe reader that I swipe when ask to input information in a query. How do I filter the unwanted characters. Apparently there are two mag stripes that are read every time I...
4
by: David Beck | last post by:
I donwnload some files for processing every day that have unwanted characters in them. In VB6 I use the InputB to read in the text and the StrConv. vLinesFromFile =...
16
by: lovecreatesbeauty | last post by:
/* When should we worry about the unwanted chars in input stream? Can we predicate this kind of behavior and prevent it before debugging and testing? What's the guideline for dealing with it? ...
3
by: et | last post by:
How can I strip out unwanted characters in a string before updating the database? For instance, in names & addresses in our client table, we want only letters and numbers, no punctuation. Is...
4
by: vvenk | last post by:
Hello: I have a string, "Testing_!@#$%^&*()". It may have single and double quotations as well. I would like to strip all chararcters others than a-z, A-Z, 0-9 and the comma. I came across...
0
by: Abhinay | last post by:
hi, this is abhinay, i have data ie xml file Ex: <root> <child1> <cc1>aaa</cc1> </child1>
6
by: lawpoop | last post by:
Hello all - I have a situation where I want to remove a string from a file and write it to disk before I do further work with it. It's a malformed xlm document with a string that causes our...
9
by: daknightuk | last post by:
I have a HTML page which posts information to a PHP page which contains a query for mysql to add records to a database I want to strip all special characters and only allow 0-9 and a-z but also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.