By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,963 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,963 IT Pros & Developers. It's quick & easy.

restrict inverted commas in textbox

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.