做輸入校驗(yàn)的時(shí)候如果你前端框架用的是bootstrap的話,首推bootstrapValidator校驗(yàn)方式,具體流程如下:
一、下載,導(dǎo)入js文件
<link type="text/css" rel="stylesheet" href="${ctx}/components/validate/css/bootstrapValidator.css" /><script type="text/javascript" src="${ctx}/components/validate/js/bootstrapValidator.js"></script><script type="text/javascript" src="${ctx}/components/validate/js/language/zh_CN.js"></script>二、
$(表單id:)({  message:'這里寫默認(rèn)提示信息';  feedbackIcons:{          valid:'glyphicon glyphicon-ok',          invalid:'glyphicon glyphicon-remove',          validating:'glyphicon glyphicon-refresh'        },   fields: {            inputName: {            validators: {              notEmpty: {                message: '時(shí)間不能為空'              },              regexp: {                 regexp: /^[0-9]+$/ ,                 message: '時(shí)間由數(shù)字組成'               },                 stringLength: {                min: 1,                max: 20,                message: '角色名長(zhǎng)度必須在1到20之間'              }          }      }   }   )網(wǎng)上有各種驗(yàn)證,當(dāng)然有自定義驗(yàn)證,如上例中的時(shí)間由數(shù)字組成。
以上所述是小編給大家介紹的BootStrapValidator校驗(yàn)方式,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!
新聞熱點(diǎn)
疑難解答