欢迎各位兄弟 发布技术文章
这里的技术是共享的
1)引入 jquery-2.2.4.min.js 和 jquery.form.js jquery-2.2.4.min.js文件见附件 jquery.form.js文件见附件
<script type="text/javascript" src="{{ asset('/assets/front/js/jquery-2.2.4.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('/assets/front/js/jquery.form.js') }}"></script>
2)使用 js
<script type="text/javascript">
$(document).ready(function () {
var $adForm = $("#adForm");
var $submitId = $("#submitId");
$submitId.click(function () {
$adForm.submit();
});
// 表单验证
$adForm.validate({
rules: {
wei_mian_pian_name: {
required: true
},
wei_mian_pian_tel: {
required: true,
pattern: /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/ ,
remote: {
url: "/admin/admin/check_username.jhtml",
cache: false
},
},
messages: {
wei_mian_pian_tel: {
pattern: "电话号码格式有误。",
remote: "电话号码已经被占用。"
}
}
});
});
</script>
3)html
<form id="adForm" enctype="multipart/form-data" action="{{ url('wei-mian-pian/edit') }}" method="post">
<input type="text" class="wanshanziliao"
value="{!! old('wei_mian_pian_name',!(empty($wei_mian_pian))?$wei_mian_pian->wei_mian_pian_name:'') !!}" id="wei_mian_pian_name"
name="wei_mian_pian_name" placeholder="请填写用户姓名,必填项" maxlength="50"/>
<input type="text" class="wanshanziliao"
value="{!! old('wei_mian_pian_tel',!(empty($wei_mian_pian))?$wei_mian_pian->wei_mian_pian_tel:'') !!}" id="wei_mian_pian_tel"
name="wei_mian_pian_tel" placeholder="请填写手机号,必填项" maxlength="50"/>
<button id="submitId" type="button" class="btn btn-default btn-block btn-lg m-top10 f16">
提交
</button>
</form>
附件 | 大小 |
---|---|
jquery-2.2.4.min_.js.txt | 83.57 KB |
jquery.form_.js.txt | 42.86 KB |