Javascript Special Characters validation


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function isSpclChar(comments)
  2. {
  3. var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
  4. var cnt=0;
  5. for (var i = 0; i < comments.length; i++)
  6. {
  7. if (iChars.indexOf(comments.charAt(i)) != -1)
  8. {
  9. cnt=cnt+1;
  10. }
  11. }
  12. if(cnt==comments.length)
  13. return false;
  14. else
  15. return true;
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.