0

I'm using the latest version of the Jquery Validation plugin which has support for validating BIC and IBAN numbers. This is part of the additional methods js which I've included and is working fine for validating IBANs, however, it fails when validating BICs. When I say fails I mean the call to validate doesn't work, not that it's incorrectly validating the BIC sequence.

Here's my code:

<asp:TextBox runat="server" ID="txtBIC" CssClass="donBic" AutoComplete="off"></asp:TextBox>

And here's my Jquery

 $('.donBic').rules('add', {
     bic: true
  });

I have to presume the 'bic' usage isn't the correct way to call that form of validation, yet this code works perfectly well for validating IBANS:

<asp:TextBox runat="server" ID="txtIBAN" CssClass="donIban" AutoComplete="off"></asp:TextBox>

  $('.donIban').rules('add', {
     iban: true
   });

Does anyone know the correct way to call BIC validation?

BIC / IBAN code in github

4

2 回答 2

0

至于您对没有 BIC 方法的评论(@Full Time Skeleton),您可以通过以下方式添加它:

将此添加到您的 onReady 事件处理程序:

$.validator.addMethod("bic", function(value, element){
    return this.optional( element ) || /^([A-Z]{6}[A-Z2-9]{1}[A-NP-Z1-2]{1})(X{3}|[A-WY-Z0-9]{1}[A-Z0-9]{2})?$/.test( value );
}, "Please specify a valid BIC code");

您可以在此处找到 addMethod 的文档页面

于 2014-01-28T11:38:04.830 回答
0

我找到了答案,从最新版本的附加方法中删除了 BIC 验证。我从问题中提供的链接中复制了它,它似乎有效。

于 2014-01-28T11:39:27.520 回答