Introduction


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