Showing posts with label IFSC. Show all posts
Showing posts with label IFSC. Show all posts

Tuesday, 7 January 2020

Bank IFSC code validation using Javascript or jquery

Introduction 

Here is a validation code for bank IFSC code.

IFSC code format : 
- Starting 4 should be only alphabets[A-Z]
Remaining 7 should be accepting only alphanumeric

Code



  1. <script type="text/javascript">  
  2. $(document).ready(function(){   
  3.       
  4. $(".ifsc").change(function () {    
  5. var inputvalues = $(this).val();    
  6.   var reg = /[A-Z|a-z]{4}[0][a-zA-Z0-9]{6}$/;  
  7.                 if (inputvalues.match(reg)) {  
  8.                     return true;  
  9.                 }  
  10.                 else {  
  11.                      $(".ifsc").val("");  
  12.                     alert("You entered invalid IFSC code");  
  13.                     //document.getElementById("txtifsc").focus();  
  14.                     return false;  
  15.                 }  
  16. });    
  17.   
  18. });  
  19. </script>  
  20.   
  21. IFSC : <input type="text" class="ifsc">