parsley.js电话数字输入以空格验证 [英] parsley.js telephone digits input validating with spaces
问题描述
我有一个电话号码输入.
I have an input for telephone number.
我想写这种格式:0175 6565 6262(带空格).但是,如果写有空格"会出错,而我写没有空格不会出错.
I would like to write this format: 0175 6565 6262 (with spaces). But if write with " " spaces so get error and I write without spaces so get not error.
这是我的HTML输入:
Here my HTML Input:
<input type="text" data-parsley-minlength="6" data-parsley-minlength-message="minlength six number" data-parsley-type="digits" data-parsley-type-message="only numbers" class="input_text" value="">
希望有人可以帮助我吗?
Hope someone can help me?
推荐答案
这是一个很好的答案,但是对于我的需求来说,范围太窄了.输入字段应容忍所有可能的输入-句号,连字符,括号,意想不到的地方的空格以及国际民俗的符号-并使用
That's a great answer, but it's a bit too narrow for my needs. Input field should be tolerant of all potential inputs – periods, hyphens, parentheses, spaces in unexpected places, plus signs for international folk – and using this document from Microsoft detailing what numbers IE11 should accept, I've come up with this:
data-parsley-pattern="^[\d\+\-\.\(\)\/\s]*$"
该列表中的每个数字都以优异的成绩通过了测试.享受吧!
Every number in that list passes the test with flying colours. Enjoy!
这篇关于parsley.js电话数字输入以空格验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!