<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script type="text/javascript">
function txtCheck(a){
var regex=/.+@.+/;
if(regex.test(a.value)){
a.style.borderColor="black";
document.getElementById("Submit1").style.enable=true;
}
else {
a.style.borderColor="red";
document.getElementById("Submit1").style.enable=false;
}
}
</script>
</head>
<body>
<form action="ok.aspx">
<input id="Text1" type="text" onblur="txtCheck(this)" />
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
<head>
<title>无标题页</title>
<script type="text/javascript">
function txtCheck(a){
var regex=/.+@.+/;
if(regex.test(a.value)){
a.style.borderColor="black";
document.getElementById("Submit1").style.enable=true;
}
else {
a.style.borderColor="red";
document.getElementById("Submit1").style.enable=false;
}
}
</script>
</head>
<body>
<form action="ok.aspx">
<input id="Text1" type="text" onblur="txtCheck(this)" />
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
如果符合格式 则允许SUBMIT
否则不允许SUBMIT 且红色提示
<head>
<title>????</title>
<script type="text/javascript">
function txtCheck(a){
var regex=/.+@.+/;
if(regex.test(a.value)){
a.style.borderColor="black";
document.getElementById("Submit1").disabled = false;
}
else {
a.style.borderColor = "red";
document.getElementById("Submit1").disabled =true;
}
}
</script>
</head>
<body>
<form action="ok.aspx">
<input id="Text1" type="text" onblur="txtCheck(this)" />
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
document.getElementById("Submit1").disabled =true;=====>document.getElementById("Submit1").disabled = "disabled";
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title> <script type="text/javascript">
function txtCheck(a){
var regex=/.+@.+/;
if(regex.test(a.value)){
a.style.borderColor="black";
document.getElementById("Submit1").disabled = "";
}
else {
a.style.borderColor="red";
document.getElementById("Submit1").disabled = "disabled";
}
}
</script></head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" onblur="txtCheck(this)" />
<input id="Submit1" name="Submit1" type="submit" value="submit" />
</div>
</form>
</body>
</html>