【发布时间】:2010-02-19 17:42:14
【问题描述】:
我正在验证的字段可能不是数字,但可能包含空格或减号。
这是用于验证电话号码字段! 所以,应该满足这些条件:(可能忘记了一个条件,如果有的话提醒我)
1- Atleast 5 numbers
2- May contain space
3- Not shorter than 5 characters
4- Not longer than 20 characters
5- May contain minus-sign
6- Not empty
if (nr.length>4 && nr.length<21 && nr!=''){
}
我应该如何编写正则表达式? 还是 if 语句?
谢谢
【问题讨论】:
标签: javascript html forms validation