table表中textarea判斷輸入空值判斷
阿新 • • 發佈:2019-02-07
function checkinput() { var tb = document.getElementById("tba"); var ret = true; for (var i = 0; i < tb.rows.length; i++) { var row = tb.rows[i]; var objCheck = row.cells[0].getElementsByTagName("INPUT")[0]; if (objCheck != null && objCheck.checked) { var cpuos = row.cells[3].getElementsByTagName("TEXTAREA")[0]; var remark = row.cells[4].getElementsByTagName("TEXTAREA")[0]; if (cpuos.value.replace(/(^\s*)|(\s*$)/g, "") == "" || remark.value.replace(/(^\s*)|(\s*$)/g, "") == "") { ret = false; break; } } } if (ret == false) { alert("輸入不能為空!");return false; } }