admin管理员组文章数量:1336092
So I'm attempting to make html forms that use the input html attribute 'pattern' however when I do so through Vue.js ponents, its creating very strange behavior. Here is a fiddle to demonstrate.
Vueponent('test', {
template:`<input type="text" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,16}"
title="Must contain at least one number and one uppercase and lowercase letter, and be between 8 and 16 characters."/>`
})
jsfiddle Demo
Breakdown of the patterns regex here (regex101 example).
Now for the life of me, I cannot figure out why the normal version validates properly, but the Vue version does not.
So I'm attempting to make html forms that use the input html attribute 'pattern' however when I do so through Vue.js ponents, its creating very strange behavior. Here is a fiddle to demonstrate.
Vue.ponent('test', {
template:`<input type="text" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,16}"
title="Must contain at least one number and one uppercase and lowercase letter, and be between 8 and 16 characters."/>`
})
jsfiddle Demo
Breakdown of the patterns regex here (regex101 example).
Now for the life of me, I cannot figure out why the normal version validates properly, but the Vue version does not.
Share asked Sep 27, 2017 at 14:02 Hex CrownHex Crown 7631 gold badge10 silver badges24 bronze badges 01 Answer
Reset to default 6Your Vue input is missing a backslash on the \d
pattern. The single \
gets interpolated away, so you need to double it.
Escaping in template literals
The backslash is used for escaping inside template literals.
本文标签: javascriptVuejs component html input pattern validation not workingStack Overflow
版权声明:本文标题:javascript - Vue.js component html input pattern validation not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742403546a2468361.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论