我遇到了一些关于财政代码验证功能的问题,我是 Bootstrap 和 jquery 的新手,并且在互联网上进行了一些搜索,我尝试了这样的事情:
<script type="text/javascript">
jQuery.validator.addMethod("codfiscale", function(id) {
var regex = /[A-Z]{6}[\d]{2}[A-Z][\d]{2}[A-Z][\d]{3}[A-Z]/;
return value. match(regex);
}, "Please insert a valid italian identification number");
</script>
这就是形式:
<form id="form">
<div id="form" class="form-group col-md-4 col-md-offset-4">
<label for="id">Codice fiscale:</label>
<input type="text" name="id" class="codfiscale"/>
</div>
<div class="form-group col-md-4 col-md-offset-4">
<label for="exampleInputPassword1">Password:</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group col-md-4 col-md-offset-4" class="col-md-3">
<button type="submit" OnClick="codfiscale" value="id" class="btn btn-primary center-block">Submit</button>
</div>
</form>
感谢您的帮助!