第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

ajax校驗(yàn)數(shù)據(jù)庫數(shù)據(jù)是否存在

ajax校驗(yàn)數(shù)據(jù)庫數(shù)據(jù)是否存在

慕工程0101907 2019-04-24 18:19:15
<!-- 查詢student_id是否存在 -->     <select id="getStudent_id" resultMap="studentMap" parameterType="int">          SELECT * from student where student_id = #{student_id}     </select>@RequestMapping("/studentID")     public Student getStudent_id(Integer student_id) {         Student student = userService.getStudent_id(student_id);         if (student==null){             System.out.println("沒有");         }else{             System.out.println("有");         }         return student;     }function check() {//js表單驗(yàn)證方法         var text = document.getElementById("xh").value;//通過id獲取需要驗(yàn)證的表單元素的值         if (text == "") {             alert("請(qǐng)輸入學(xué)號(hào)!");//彈出提示             return false;//返回false(不提交表單)         }         if (!(/(^[1-9]\d*$)/.test(text))) {             alert("請(qǐng)輸入學(xué)號(hào)!");//彈出提示             return false;//返回false(不提交表單)         }         var student_id=$("#student_id").val();         $.ajax({            url:"<%=basePath%>user/studentID",            type:"post",            data:{"student_id":student_id},            dataType:"json",           success:function(data){                if (data!=null ) {                    alert("有");             }else if(data==null && username !=''){                 alert("沒有");             }                xmlhttp.open("GET","getcustomer.asp?q="+str,true);                xmlhttp.send();                //alert("啊啊啊");           }         });         return true;//提交表單     } </script> <body>     <div class="listDIV">         <table border="1" width="50%" height="50%" style="text-align: center;">             <form action="<%=basePath%>user/one" method="post">                 <input type="text" id="xh" name="student_id" placeholder="根據(jù)學(xué)號(hào)查詢">                 <button class="glyphicon glyphicon-select" onclick="return check();">查詢</button>             </form>我用ssm做的增刪改查,搜索我想先校驗(yàn)一下數(shù)據(jù)庫數(shù)據(jù)是否存在,存在就直接跳轉(zhuǎn)查詢,不存在就彈窗提示,中止提交表單,JS代碼是我粘過來的,不會(huì)JS,有錯(cuò)誤希望能告訴我如何改正,謝謝
查看完整描述

3 回答

?
一只斗牛犬

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超2個(gè)贊

  1. form表單

<form action="<%=basePath%>user/one" method="post" onsubmit="return check(this)">
        <input type="text" id="xh" name="student_id" placeholder="根據(jù)學(xué)號(hào)查詢">
        <button class="glyphicon glyphicon-select">查詢</button>
</form>
  1. js表單校驗(yàn)

function check(form) {
    if (form.student_id.value == '') { 
        alert("查無此人"); 
        form.student_id.focus();
        return false;
    }
    return true;
}
  1. java后端

@Controller
@RequestMapping("/user")
public class Xxx{

    @RequestMapping("/one")
  public Student getStudent_id(Integer student_id) {

    }
}


查看完整回答
反對(duì) 回復(fù) 2019-05-13
  • 3 回答
  • 0 關(guān)注
  • 871 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)