判断输入的是否为空或非数字然后弹窗提示中止提交表单

 function check()
    {
    var id=document.getElementById("xh");
    if(text.value==null || text.value==" "){ 
        alert("请输入学号!");
        retrun false;
    }  
    }
</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="根据学号查询">
                <button class="glyphicon glyphicon-select" onclick="check()">查询</button>
            </form>

写的SSM增删改查,JS不太会。。。。。

看半天都没看出你想表达什么意思?判断空你已经写了,再来个正则判断下是否为数字不就可以了吗

function check(){//js表单验证方法
var text=document.getElementById("xh").value;//通过id获取需要验证的表单元素的值
var re = /^[0-9]+.?[0-9]*/;//判断字符串是否为数字//判断正整数/[1−9]+[0−9]∗]∗/
if(text=="" && text!=isNaN){//当上面获取的值为空时
alert("请输入学号!");//弹出提示
return false;//返回false(不提交表单)
} else if(!re.test(nubmer)) {
alert("请输入数字!");
return false;//返回false(不提交表单)
}
return true;//提交表单
}

你得isNaN函数用法也不对。
说明
isNaN() 函数可用于判断其参数是否是 NaN,该值表示一个非法的数字(比如被 0 除后得到的结果)。
如果把 NaN 与任何值(包括其自身)相比得到的结果均是 false,所以要判断某个值是否是 NaN,不能使用 == 或 === 运算符。正因为如此,isNaN() 函数是必需的。

 实例
检查数字是否非法:
<script>

document.write(isNaN(123));
document.write(isNaN(-1.23));
document.write(isNaN(5-2));
document.write(isNaN(0));
document.write(isNaN("Hello"));
document.write(isNaN("2005/12/12"));

</script>
输出:
false
false
false
false
true
true

return都打错了,而且要阻止表单提交,dom对象得return check的返回值才行


<script>
    function check() {
        var id = document.getElementById("xh");
        if (!/^\d+$/.test(id.value)) {
            alert("请输入学号!");
            return false;
        }
    }</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="根据学号查询">
                <button class="glyphicon glyphicon-select" onclick="return check()">查询</button>
            </form>