问题描述
想要一些在使用javascript验证的文本框中插入值的帮助,其中应插入字母,数字和某些特殊字符,例如
(\-)仅.
我曾经做过的是var re =/^ [a-zA-Z0-9] + $/;用于文本框
插入字母和数字.
并且以为var re =/^[a-zA-Z\0-9-].+$/;可以,但是相反
它需要所有特殊字符.也尝试使用
var re =/^[a-zA-Z\0-9-].+$/;和var re =/^ [a-z,A-Z,0-9,\-,\\\\]] * $/;这两个exp插入字母数字和-字符,但不插入\. \是一个元字符,因此也尝试使用\\,但是即使这样也不起作用.在表达式中var re =/^[a-zA-Z\0-9-].+$/;或var re =/^ [a-z,A-Z,0-9,\-,\\\\\] * $/;我只想要一个加\以及字母数字字符和-.
谢谢.
Hi,
Wanted some help with inserting values in a text box with javascript validation wherein it should insert letters, numbers and certain special characters like
(\ -) only.
What I used to do is var re = /^[a-zA-Z0-9]+$/; for the text box
which inserts letters and numbers.
and thought var re = /^[a-zA-Z\0-9-].+$/;would work but instead
it takes all special characters.Also tried using
var re = /^[a-zA-Z\0-9-].+$/; and var re = /^[a-z,A-Z,0-9,\-,\\\\]*$/; these two exp inserts alphanumeric and - characters but does not insert \. \ is a metacharacters itself hence also have tried using \\ but even this does not work. In exps var re = /^[a-zA-Z\0-9-].+$/; or var re = /^[a-z,A-Z,0-9,\-,\\\\]*$/; I just want is an added \ along with alphanumerics chars and -.
Thank You.
推荐答案
这篇关于Java脚本正则表达式中的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!