Jump to content

Double Quote


DaNuGai

Recommended Posts

hey, here's a better one :)

<input type="text" onKeyPress="return ckeck();">function check(){  return (event.keyCode != 34);		// double quot}

this is for banning, and the follow one is of replacing

<input type="text" onKeyPress="return ckeck();">function check(){  if (event.keyCode == 34){		// double quot	var pos = document.selection.createRange();	pos.text = "'";	return false;  } else	return true;}

if you wanna write something likes a forum, or your purpose of doing such restriction or replacement is for protecting data sent to your server or blocking trouble makers for ruinning your layout. i would suggest you to do this in the server side as the JavaScript function can be easily turned off even by an idoit that makes your intrigging protection codes useless. for instant, if you use php, you may try htmlspecialchars() and it will be enough and easy for the purpose :)

Link to comment
Share on other sites

First of all, I want to thank you for your help....I am actually using JSPs & servlets, so I am not quite sure how I can implement this on the server side. I am validating the data through the servlet but it doesn't catch Double Quotes since it only receives the value of that INPUT field.

hey, here's a better one :)
<input type="text" onKeyPress="return ckeck();">function check(){  return (event.keyCode != 34);		// double quot}

this is for banning, and the follow one is of replacing

<input type="text" onKeyPress="return ckeck();">function check(){  if (event.keyCode == 34){		// double quot	var pos = document.selection.createRange();	pos.text = "'";	return false;  } else	return true;}

if you wanna write something likes a forum, or your purpose of doing such restriction or replacement is for protecting data sent to your server or blocking trouble makers for ruinning your layout. i would suggest you to do this in the server side as the JavaScript function can be easily turned off even by an idoit that makes your intrigging protection codes useless. for instant, if you use php, you may try htmlspecialchars() and it will be enough and easy for the purpose :)

Link to comment
Share on other sites

Well we do not have a Java forum so posting int he General forum will cause less confusion. By posting your question in the JavaScript forum we all assumed you wanted a solution in JavaScript.To do this on server side you will have to capture the input field and use JSP version of the String.Replace function to change (") to (').As far as preventing the user from not even entering a double quote that must be done with Javascript since it is on the client side.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...