BootStrapValidator表单验证插件的坑还真很多,又让我碰上一个...
BootStrapValidator验证的表单中只可有一个type="submit"
的按钮。我这样写了以后 (代码以下),点击其它按钮仍会触发验证...
//示意 <form> ... <button type="submit">提交</button> ... <button>重置</button> <button>取消</button> ... </form>
一开始是写成这样的,可是 问题来了,点击其它的按钮也会触发 表单验证...
//示意 <form> ... <button type="submit">提交</button> ... <button type="button">重置</button> <button type="button">取消</button> ... </form>
这样写点击除提交
外的按钮就能够避免触发验证了,<button>
标签的type
属性有三个值,分别是submit
、button
和reset
,在BootStrapValidator的验证表单中只能有一个type=submit
的按钮, 若是type
属性不写或为空,那么就会被自动识别为type=submit
,点击时会触发验证。而type=button
能够为多个,因此能够在不须要加验证的按钮给type
属性设为button
就行了。而type=reset
的按钮点击时也会触发验证。具体的各位读者老爷们能够自行验证...插件