<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>可编辑表格</title>
<style>
table {
width: 500px;
border: 1px;
}
td {
background-color: pink;
}
th {
background-color: rgb(0, 162, 255);
}
</style>
</head>
<script></script>
<body>
<table align="center">
<tr>
<th width="100px">学号</th>
<th width="100px">姓名</th>
<th width="100px">年龄</th>
</tr>
<tr>
<td contenteditable="true" id="te">0001</td>
<td>小明</td>
<td contenteditable="true">19</td>
</tr>
<tr>
<td contenteditable="true" id="te">0002</td>
<td>张三</td>
<td contenteditable="true" id="te">18 </td>
</tr>
<tr>
<td contenteditable="true">0003</td>
<td>李四</td>
<td contenteditable="true">22</td>
</tr>
<tr>
<td contenteditable="true">0004</td>
<td>王二</td>
<td contenteditable="true">20</td>
</tr>
if(condition.length<4){}
</table>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>可编辑表格</title>
<style>
table {
width: 500px;
border: 1px;
}
td {
background-color: pink;
}
th {
background-color: rgb(0, 162, 255);
}
</style>
</head>
<script></script>
<body>
<table align="center">
<tr>
<th width="100px">学号</th>
<th width="100px">姓名</th>
<th width="100px">年龄</th>
</tr>
<tr>
<td contenteditable="true" onblur="changeNum(1)" id="te1">0001</td>
<td>小明</td>
<td contenteditable="true">19</td>
</tr>
<tr>
<td contenteditable="true" id="te">0002</td>
<td>张三</td>
<td contenteditable="true" id="te">18 </td>
</tr>
<tr>
<td contenteditable="true">0003</td>
<td>李四</td>
<td contenteditable="true">22</td>
</tr>
<tr>
<td contenteditable="true">0004</td>
<td>王二</td>
<td contenteditable="true">20</td>
</tr>
</table>
<script>
function changeNum(e){
var domValue = document.getElementById('te1').innerHTML
if (domValue.length<4){
alert('学号长度不能小于4位')
}
}
</script>
</body>
</html>
详细的描述下问题?没太懂你的意思
value.length