开发者

validation using html5 pattern attribute for pin

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜