![](/img/trans.png)
[英]Regular expression not working with jquery form validation plugin
[英]Validation with regular expression and jQuery Plugin
我喜歡使用JavaScript進行客戶端驗證。 為此,我在這里使用jQuery插件Validate()觀看: http : //docs.jquery.com/Plugins/Validation/Methods
通過單擊提交按鈕,我想將iput字段中的ID與正則表達式進行比較。 我該如何解決?
現在,我這樣做是這樣的:
<form id="checkoutFormBean" action="/view/checkout?execution=e3s1" method="POST">
<li>
<input id="id" name="id" class="fieldError required number" tabindex="12" value="" maxlength="2048" type="text">
</li>
<script type="text/javascript">
$(document).ready(function(){
$("#checkoutFormBean").validate({
id: "required",
id: {
equalTo: "/^2099[0-9]{9}$/"
}
});
});
</script>
但是它不起作用
提交后,您只需要使用規則進行驗證。請查看以下網址。您將在此處了解如何指定規則。
例如:
$("#checkoutFormBean").validate({
rules: {
name: {
required: true,
equalTo: "/^2099[0-9]{9}$/"
}
}
});
希望這對您有所幫助:-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.