先通过bootstrap验证再发送ajax请求的完整代码及脚本先通过bootstrap验证再发送ajax请求的完整代码及脚本
专科生可以考公务员吗<form class="needs-validation" autocomplete="off" novalidate=""
新春短信action="{% url 'user_register' %}" method="post"id="regform-two">
冬天空调温度多少最佳{% csrf_token %}
<div class="form-group">
<label>昵称</label>
<input class="form-control"type="text" name="name" placeholder="6-10位英⽂数字账户"
pattern="[a-z0-9A-Z]{6,12}" required="">
<div class="invalid-feedback">请输⼊你的⽤户名.</div>
</div>
<div class="form-group">
<label>邮箱</label>
<input class="form-control"type="email" placeholder="demo@example" name="email"
pattern="^[a-z0-9A-Z]+([-_.][a-z0-9A-Z]+)*@([a-z0-9A-Z]+[-.])+[a-z0-9A-Z]{2,6}$"
required="">
<div class="invalid-feedback">请输⼊⼀个有效的邮箱地址..</div>
</div>
<div class="form-group">
十大贫困县<label>密码</label>
<div class="password-toggle">
<input class="form-control"type="password" name="pwd" required=""
placeholder="6-10位英⽂数字密码" pattern="[a-z0-9A-Z]{6,12}">
<label class="password-toggle-btn">
<input class="custom-control-input"type="checkbox"><i
class="czi-eye password-toggle-indicator"></i><span
class="sr-only">显⽰密码</span>
</label>
</div>
</div>
<div class="form-group">
<label>重复密码</label>
<div class="password-toggle">
<input class="form-control"type="password" name="confirm_pwd" required=""
placeholder="重复相同的英⽂数字密码" pattern="[a-z0-9A-Z]{6,12}">
<label class="password-toggle-btn">
<input class="custom-control-input"type="checkbox"><i
class="czi-eye password-toggle-indicator"></i><span
class="sr-only">显⽰密码</span>
</label>
</div>
</div>
<button class="btn btn-primary btn-block btn-shadow"id="reg_sub_two"type="submit">⽴即注册
</button>
</form>
<script>
$("#regform-two").submit(function(event){
if($(this)[0].checkValidity()===false){
event.preventDefault();// 阻⽌提交表单
六一儿童节朋友圈配图event.stopPropagation();
}else{
$.ajax({
type:"post",//⽅法类型
url:"/user/register/",
泡菜制作data:$("[name='loginform']").serialize(), success:function(data){
alert('成功');
},
error:function(date){
alert('失败');
}
});
}
})
</script>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论