jquery(function() { // 提示框 jquery('.icon2').on('click', function(e) { jquery(this).next().show(); jquery(document).one('click', function() { jquery('.statecase').hide(); }) e.stoppropagation(); /*stoppropagation();方法可以阻止把事件分派到其他节点*/ }) // 增删1 var flag = true var add = 0 jquery('.addtr').on("click", function() { if (flag) { jquery('.table2-tr2').show(); flag = false } else { jquery(this).parent().parent().next().clone(true).appendto(".table2") jquery(this).parent().parent().parent().find(":last-child").addclass('table2-tr2-' + add); add++; } }) jquery('.deltr').on('click', function() { var trindex = jquery(this).parent().parent().index() if (trindex > 1) { jquery(this).parent().parent().remove(); } else { jquery(this).parent().parent().hide(); flag = true } }) // 增删2 var add1 = 0 function adddatetime(tar) { tar.datetimepicker({ format: 'y/m/d', lang: 'ch', timepicker: false }); } jquery('.addframe').on('click', function() { add1++; jquery(this).prev().after(jquery('.table4:first').clone().addclass('table4-' + add1)); jquery('.table4:not(:first) .line').show(); jquery('.table4:not(:first) .delcase').show(); var inputsatart = jquery(".table4-" + add1).find(".form-start"); var inputend = jquery(".table4-" + add1).find(".form-end"); inputsatart.attr("id", "start" + add1).val(""); inputend.attr("id", "end" + add1).val(""); console.log(inputsatart); console.log(inputend); adddatetime(jquery("#start" + add1)); adddatetime(jquery("#end" + add1)); jquery('.delcase').unbind("click").on('click', function() { jquery(this).parent().parent().parent().parent().remove(); }) }); // 验证手机号 function isphoneno(phone) { var pattern = /^1[34578]\d{9}jquery/; return pattern.test(phone); } /*手机号判断*/ function usertel(inputid) { jquery(inputid).blur(function() { if (isphoneno(jquery.trim(jquery(inputid).val())) == false) { jquery('.tips1').show(); } jquery(inputid).focus(function() { jquery('.tips1').hide(); }); }); }; usertel('#telephone'); // 服药不舒服情况 jquery("#adsum2").on('click', function() { jquery('#textarea1').show(); }) jquery("#nothing2").on('click', function() { jquery('#textarea1').hide(); }) jquery("#dimness").on('click', function() { jquery('#textarea1').hide(); }) jquery("#adsum3").on('click', function() { jquery('#textarea2').show(); }) jquery("#nothing3").on('click', function() { jquery('#textarea2').hide(); }) jquery("#dimness3").on('click', function() { jquery('#textarea2').hide(); }) // 报告人信息 jquery('#speaker-yes').on("click", function() { jquery(".table8").hide(); }) jquery('#speaker-no').on("click", function() { jquery(".table8").show(); }) // 其它情况 jquery("#other-result").on("click", function() { jquery('.other-result').show(); }) function first() { var namefirst = jquery("#namepeople").val(); var weightfirst = jquery("#weight").val(); var telephone = jquery("#telephone").val(); var agefirst = jquery("#agefirst").val(); var nameselect = jquery('input[name="sex"]').is(':checked'); var ageselect = jquery('input[name="age"]').is(':checked'); console.log(namefirst, weightfirst, telephone, agefirst, nameselect, ageselect) if (namefirst != '' && weightfirst != '' && telephone != '' && agefirst != '' && nameselect == true && ageselect == true) { jquery('.msgcenter1').hide(); jquery('.msgcenter2').show(); } else { alert('您有信息未填写!') } } // 下一步判断 jquery('#btnfirst').on('click', function() { first(); }); jquery('.step-2').on('click', function() { first(); }) jquery('.step-1').on('click', function() { jquery('.msgcenter2').hide(); jquery('.msgcenter3').hide(); jquery('.msgcenter1').show(); }) jquery('.step-2').on('click', function() { jquery('.msgcenter2').show(); jquery('.msgcenter1').hide(); jquery('.msgcenter3').hide(); }) function twopage() { var selectp2 = jquery('#selectpage2 option:selected').text(); var drugname = jquery('#drugname').val(); var drugway = jquery('#drugway').val(); var drugcause = jquery('#drugcause').val(); console.log(selectp2, drugname, drugway, drugcause) if (selectp2 != '' && selectp2 != '请选择' && drugname != '' && drugway != '' && drugcause != '') { jquery('.msgcenter2').hide(); jquery('.msgcenter1').hide(); jquery('.msgcenter3').show(); } else { alert('您有信息未填写!') } } jquery('#btntwo').on('click', function() { twopage(); }) jquery('.step-3').on('click', function() { twopage(); }) function threepage() { var appeartime = jquery('#appeartime').val(); var appearcourse = jquery('#appearcourse').val(); var appearagain = jquery('input[name="same"]').is(':checked'); var appearself = jquery('input[name="self"]').is(':checked'); console.log(appeartime, appearcourse, appearagain, appearself) if (appeartime != '' && appearcourse != '' && appearagain == true && appearself == true) { alert("提交成功") } else { alert('您有信息未填写!') } } jquery('.stepbtn').on('click', function() { alert('我我') threepage(); }) })