|
javascript判断多个文本框都不能为空的函数小事例 function FunCheck() { //不为空的文本框的ID if (!CheckFields("txtID,corpID,txtCar,weight,txtTime")) { alert("****不能为空"); return; } }
function CheckFields(txtChecks) { var oArray = txtChecks.split(","); for (var i=0;i<oArray.length;i++) { if (document.getElementById(oArray[i]).value.replace(/\s/g,"") == "") { try { document.getElementById(oArray[i]).focus(); } catch (e) {} event.returnValue = false; return false; } } return true; }
//比较两文本框中数字大小
function (ID1,ID2) { if (!(Number(document.getElementById("ID1").value) > Number(document.getElementById("ID2").value))) { alert("毛重一定得大于皮重!"); event.returnValue = false; } }
|