Regex Expression Conditional Validation In JavaScript

Actually i am trying to add Validation to textbox field in ASP.NET.The validation is like first 2 characters must be Alphabets and last two characters Numeric in a max length of 4..Here is the code block function IsValidate(evt) { var charCode = (evt.which) ? evt.which : evt.keyCode; var Con = String.fromCharCode(charCode); var exp= new RegExp("[A-Za-z]{2}[0-9]{2}"); if(exp.match(Con)) { return true; } else { return false; } } Any help will be well appreciated...
Why are you converting the keycode pressed to a char and then validating that. I don't think that contains the text in the textbox, does it?

以上就是Regex Expression Conditional Validation In JavaScript的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏