[英]Regular expression to allow + at the start and digits
我有這個代碼。 我如何將其更改為僅允許數字和 + 在開始時。
$(document).on("input", ".numeric>input , .numeric", function() {
this.value = this.value.replace(/[^0-9\.]/g,'');
});
讓我知道,非常感謝!
您可以輕松地將 + 添加為第一個數字,據我了解您正在嘗試匹配電話號碼,您的代碼必須如下所示:
$(document).on("input", ".numeric>input , .numeric", function() {
this.value = this.value.replace(/[+0-9\.]/g,'');
});
這是一個漂亮的在線工具,您可以在其中輕松構建它們,您不必記住所有內容:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.