I am trying to validate pin number ( 6 digits always). I am using,
[0-9]{6}
Which does the job but it makes field compulsory.
How to make 开发者_如何学Goit optional?
^([0-9]{6})?$
^
ist string start, $
is string end, and the ()?
says: My content exactly once or nothing.
However, if I read the spec correctly, and a quick test in FF4 doesn't deceive me, this might not be necessary, as long as you don't add the required
attribute, too (in which case it would be an error).
精彩评论