Preventing certain characters

P

Phil Amey

I would like to prevent certain characters from being input to some form cells, e.g. ~ # ' and so on.

I'm currently using this format to check the input data of cells -

if (document.form1.EMAIL.value == ""){
alert("Please complete the E-Mail: field")
document.form1.EMAIL.focus()
validFlag = false
return validFlag
}

It would also be nice to learn how to check this particular cell for a valid email address, I assume that you search for the @.

Could someone show me how I could modify this to prevent characters of my choice.

Kindest Regards - Philip Amey
 
B

Brian Genisio

Phil said:
I would like to prevent certain characters from being input to some form cells, e.g. ~ # ' and so on.

I'm currently using this format to check the input data of cells -

if (document.form1.EMAIL.value == ""){
alert("Please complete the E-Mail: field")
document.form1.EMAIL.focus()
validFlag = false
return validFlag
}

It would also be nice to learn how to check this particular cell for a valid email address, I assume that you search for the @.

Could someone show me how I could modify this to prevent characters of my choice.

Kindest Regards - Philip Amey

For removing special characters, use the javascript string methods
(indexOf, substr, split, join, etc) to do it the way you need.

For email addresses, I like to make sure there is an @ character, and in
the host side, there is a high-level domain *.* (*.com, *.net, *.edu,
etc, but stay with *.*, since it it is tough to know which high-level
domain names will exist in the future)

VERY IMPORTANT: Do not rely on javascript to make sure your server-side
form handler gets the correct input. If my browser does not support
javascript, or I simply send the HTTP request by hand, I can _easily_
circumvent the special characters, and break your form handler, if it
does not handle the special characters as well.

VERY IMPORTANT: Do not disregard the previous statement :)

Good luck,
Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top