Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples Java Script
 

Check for Special characters


Code ResourceAuthor: Durga Prasad  

Difficulty Level:

Published: 5th Nov 2006   Read: 3858 times  

Filed in: Java Script
Add Comment


 


Check for Special characters in the text box

 


Sample Code
  1.  
  2. <html>
  3. <head>
  4. <script language="javaScript">
  5.  
  6. function validate_field(field)
  7. {
  8.         value=field.value;
  9.  
  10.         var invalids = "!@#$%"'^&*()~,'<>/?;:|[]{}+=`*";
  11.         for(i=0; i<invalids.length; i++)
  12.         {
  13.                 if(value.indexOf(invalids.charAt(i)) >= 0 )
  14.                 {
  15.                         alert(field.name+"Contains Invalide characters");
  16.                         break;
  17.                 }
  18.         }
  19.  
  20. }
  21. </script>
  22. </head>
  23. <body>
  24. <form name="ValidateForm">
  25. Name:<input type="text" name="Name">
  26. <input type="button" value="Check" onClick="validate_field(Name)">
  27. </body>
  28.  
Copyright GeekInterview.com


Next: JavaScript Password Strength Meter


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. srinivasaraobora5408
2. Durga Prasad3859
3. chowsys2582
4. iamdvr1864

Active Coders

# Coder NameCodes
1. srinivasaraobora3
2. chowsys2
3. Durga Prasad1
4. iamdvr1

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape