DEDECMS织梦自定义表单ajax判断提交不跳转处理
更新时间:2020-03-13 10:59 已阅读: 次 | 作者:骏马网络 来源:潍坊做网站
DEDECMS织梦自定义表单提交成功后返回当前页面的方法。
自定义表单通过ajax判断,提交不用跳转页面,提高用户体验。
自定义表单通过ajax判断,提交不用跳转页面,提高用户体验。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=9">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name='viewport' content="width=device-width, viewport-fit=cover" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
<meta name="HandheldFriendly" content="true">
<title>标题</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet" href="/skin/css/common.css">
<link rel="stylesheet" href="/skin/css/css.css">
<script src="/skin/js/jquery-1.11.3.min.js"></script>
<script src="/skin/js/common.js"></script>
<!--[if lt IE 9]>
<script src="https:// oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js">
</script>
<script src="https:// oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js">
</script>
<![endif]-->
</head>
<body ontouchstart>
<!--WRAP-->
<div class="WRAP">
{dede:arclist row='6'orderby='id' orderway='asc' titlelen='50'}
<div><img class="db ww100" src="[field:litpic]" alt="[field:title/]"></div>
{/dede:arclist}
<div class="formDiv">
<div>
<img class="img1" src="/skin/images/7.png" alt="">
<img class="db img2" src="/skin/images/8.png" alt="">
<p class="fs28 cor0 mgt16">价值299元钢琴体验套餐</p>
<form action="/plus/diy.php" class="pdt16" enctype="multipart/form-data" method="post" id="form1" name='myform' onSubmit='return Checkfeedback();'>
<input type="hidden" name="action" value="post" />
<input type="hidden" name="diyid" value="1888" />
<input type="hidden" name="do" value="2" />
<div class="mgt16 rel pc1">
<input type="text" id="picker" name='city' class="input1 pc6" placeholder="所在城市">
</div>
<div class="mgt16 rel">
<input type="text" class="input1 pc2" id='old' name='old' placeholder="你或孩子年龄">
</div>
<div class="mgt16 rel">
<input type="text" class="input1 pc3" id='name' name='name' placeholder="姓名">
</div>
<div class="mgt16 rel">
<input type="text" class="input1 pc4" id='tel' name='tel' placeholder="手机">
</div>
<div class="mgt16 rel">
<div class="ks">
<p class="pc5 p1">预约课程形式</p>
<div class="pdl105">
<p class="mgt20">
<label class="lab1">
<input type="checkbox" name='order[]' checked value='线上钢琴课'><i class="lab1-i"></i><span>线上钢琴课</span>
</label>
</p>
<p class="mgt30">
<label class="lab1">
<input type="checkbox" name='order[]' value='线下钢琴课'><i class="lab1-i"></i><span>线下钢琴课</span>
</label>
</p>
</div>
</div>
</div>
<!--<p class="mgt20 fs24 corff0004">*错误提示语位置</p>-->
<input type="hidden" name="dede_fields" value="city,text;old,text;name,text;tel,text;order,checkbox" />
<input type="hidden" name="dede_fieldshash" value="d7061bc5adb476dcef376cd5c5cf643b" />
<input type="button" id='subbb' class="db mgt40 submit" value="马上提交立赠儿童音乐绘本">
</form>
</div>
</div>
</div>
<!--WRAP End-->
<div class="footer">
<img class="ww100" src="/skin/images/23.png" alt="">
</div>
<!--二维码弹窗-->
<div class="pop" id="pop">
<div>
<a href="###" class="db close"><img src="/skin/images/15.png" alt="关闭按钮"></a>
<img src="/skin/images/14.png" alt="" class="db c-b w127">
<img src="/skin/images/19.png" alt="" class="db mgt20 c-b w192">
<div class=" pop-1"><img src="/skin/images/13.png" alt=""></div>
<img src="/skin/images/18.png" alt="" class="db c-b w422">
</div>
</div>
<script src="/skin/js/picker.min.js"></script>
<script src="/skin/js/city.js"></script>
<script src="/skin/js/index.js"></script>
<script>
$("#subbb").click(function() {
var city_main = $("#picker").val();
var name_main = $("#name").val();
var old_main = $("#old").val();
var reg1 = /^[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*$/;
var mobile_main = $("#tel").val();
var reg2 = /^1[3|4|5|7|8][0-9]{9}$/;
if (city_main == '') {
alert('城市不能为空!');
return false }else if
(old_main == '') {
alert('年龄不能为空!');
return false }else if
(name_main == '') {
alert('姓名不能为空!');
return false } else if (!reg1.test(name_main)) {
alert('请输入有效的姓名!');
return false }
if (mobile_main == '') {
alert('手机不能为空!');
return false } else if (!reg2.test(mobile_main)) {
alert('请输入有效的手机号码!');
return false }
$.ajax({
cache: true,
type: "POST",
url:"/plus/diy.php",
data:$('#form1').serialize(),
success: function(data) {
// alert('加盟申请提交成功,客服将在12小时内联系您,请留意手机或者微信!');
$('#pop').show();
$('#form1')[0].reset();
}
});return false;
})
$('.close').click(function(){
$('#pop').hide();
});
/*
$('.submit').click(function(){
$('#pop').show();
});
$('.close').click(function(){
$('#pop').hide();
});
*/
</SCRIPT>
</body>
</html>
文章引用:https://www.wfwz.net/news/231.html如需转载,请注明出处。