使用jquery进行Pan Number格式的文本框验证 [英] Validation on textbox using jquery for pan Number format

查看:113
本文介绍了使用jquery进行Pan Number格式的文本框验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的网站应用程序中添加Pan no,但是我必须使用jquery进行验证,以便前5个no.应该是字母,然后是4号.应该是数字,最后一个问题应该是字母.

I have to add Pan no in my website Application but i have to use jquery for validation so that first 5 no. should be alphabet then 4 no. should be numeric and the last Questions should be alphabet.

$('#txtPANNumber').keypress(function (event) { 
var key = event.which; 
var esc = (key == 127 || key == 8 || key == 0 || key == 46); 
//alert(key); 
//var nor = $("#txtPANNumber").mask("aaaaa9999a"); 
var regExp = /[a-zA-z]{5}\d{4}[a-zA-Z]{1}/; 
var txtpan = $(this).val(); 
if (txtpan.length < 10 ) { 
 if( txtpan.match( regExp) ){ 
  //event.preventDefault(); 
 } 
} else { event.preventDefault(); } });

请提供一些解决方案

推荐答案

可以做到

/[a-zA-z]{5}\d{4}[a-zA-Z]{1}/

检查 此处

代码

$('#txtPANNumber').change(function (event) {     
 var regExp = /[a-zA-z]{5}\d{4}[a-zA-Z]{1}/; 
 var txtpan = $(this).val(); 
 if (txtpan.length == 10 ) { 
  if( txtpan.match(regExp) ){ 
   alert('PAN match found');
  }
  else {
   alert(Not a valid PAN number);
   event.preventDefault(); 
  } 
 } 
 else { 
       alert('Please enter 10 digits for a valid PAN number');
       event.preventDefault(); 
 } 

});

这篇关于使用jquery进行Pan Number格式的文本框验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆