2
我想验证HTML表单的每个字段onblur。验证消息得到显示,但不跨越框的整个水平空间。 我希望它是这样的。Validation Message on HTML form will in line
Customer Name: TextBox *Customer Name Must Not Be Blank
但它显示:
Customer Name: TextBox *Customer
Name Must
Not Be
Blank
这是我的代码:
<form method="post" name="customer" action="newcustcheck.php" onblur="return Validate()"
onKeyUp="return Validate()">
<table width="300">
<tr>
<td>Customer Name:</td>
<td><input type="text" name="name" ></td>
<td> <label class="message" id="message" ></td>
</tr>
</table>
</form>
CSS
form {
width: 400px;
background:#FFD700;
color: #000000;
font: small Verdana, sans-serif;
position: absolute;
top: 200px;
left: 550px;}
.message{color:#FF0000;
font-size: small;
font-weight: bold; }
的JavaScript
function Validate(){
if(x==null || x==""){
document.getElementById('message').style.visibility="visible";
document.getElementById('message').innerHTML="Customer Name must not be blank";
}
else{
document.getElementById('message').style.visibility="hidden";
}
}
你给表格400像素宽度和形式只有300像素是什么问题? – AMember
400px是窗体的大小,300px是文本框的大小。我想在左边的100像素空间中显示错误信息。 – user3402248
错误信息没有足够的空间。你想让它溢出黄色块? – dfsq