restrict inverted commas in textbox

D

divaof_7

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.
 
J

Jeremy

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
 
D

David Dorward

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.
 
J

Jeremy

David said:
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
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top