469,625 Members | 1,089 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

restrict inverted commas in textbox

I've a textbox field, where user enters his name. I want to restrict
him from entering double and singls inverted commas.What kind of
function should i write.

Jul 6 '06 #1
3 2341
di******@yahoo.com wrote:
I've a textbox field, where user enters his name. I want to restrict
him from entering double and singls inverted commas.What kind of
function should i write.
If you want to do this to prevent the input from breaking a server-side
script, then you mustn't use javascript. Validate the input on the
server side instead. Otherwise, people without javascript will still
enter the invalid characters and your server-side code will break.

If that's not the case, you can use something like this:

<input type="text" onkeyup="this.value=this.value.replace(/\'/g, '')" />

Jeremy
Jul 6 '06 #2
Jeremy wrote:
di******@yahoo.com wrote:
>I've a textbox field, where user enters his name. I want to restrict
him from entering double and singls inverted commas.What kind of
function should i write.
If you want to do this to prevent the input from breaking a server-side
script, then you mustn't use javascript. Validate the input on the
server side instead.
Using JavaScript for this is not a problem.
Depending on JavaScript for this is.

A client side check can speed things up for the user and save server round
trips. The cost is that the function has to be implemented twice.

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 6 '06 #3
David Dorward wrote:
Using JavaScript for this is not a problem.
Depending on JavaScript for this is.

A client side check can speed things up for the user and save server round
trips. The cost is that the function has to be implemented twice.
Thanks for the clarification. That's what I meant, but it came out a
bit glib.

Jeremy
Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.