How to avoid the Special characters? 2 Answer(s) 4 years and 5 months ago
Posted in : JDBC
View Answers
March 31, 2009 at 4:07 PM
hi friend,
To avoid special characters we have imposed some validations on the textfields in jsp page.
<html> <script> function validate() { var chars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; for (var i = 0; i < document.form.text1.value.length; i++) { if (chars.indexOf(document.form.text1.value.charAt(i)) != -1) { alert ("Text1 is having special characters.Please remove them."); return false; } } for (var i = 0; i < document.form.text2.value.length; i++) { if (chars.indexOf(document.form.text2.value.charAt(i)) != -1) { alert ("Text2 is having special characters.Please remove them."); return false; } } for (var i = 0; i < document.form.text3.value.length; i++) { if (chars.indexOf(document.form.text3.value.charAt(i)) != -1) { alert ("Text3 is having special characters.Please remove them."); return false; } } for (var i = 0; i < document.form.text4.value.length; i++) { if (chars.indexOf(document.form.text4.value.charAt(i)) != -1) { alert ("Text4 is having special characters.Please remove them."); return false; } } for (var i = 0; i < document.form.text5.value.length; i++) { if (chars.indexOf(document.form.text5.value.charAt(i)) != -1) { alert ("Text5 is having special characters.Please remove them."); return false; }