I am new to javascript and I would like to validate a field.
If there is no information in the field then there is an error message on the html page.
When information is then entered the message will disappear.
This is the code that I have so far.
Most of this is doing what I want to do, however it is leaving the red bar across the page when information is entered.
I would be very grateful if someone could advise me on what to do next.
If there is no information in the field then there is an error message on the html page.
When information is then entered the message will disappear.
This is the code that I have so far.
Code:
<html>
<head>
<style type="text/css">
<!--
.errormessage {
background-color: Red;
font-family: Arial, Helvetica, sans-serif;
font-size: 12pt;
font-weight: bold;
color: White
}
-->
</style>
<script language="JavaScript">
function addCheck() {
if ((test.order_details.value.length==0) || (test.order_details==null)) {
somename.innerHTML="You Did Not Enter Any Order Details";
test.order_details.focus();
return false;
}
else
{
somename.innerHTML="";
test.order_details1.focus();
}
}
</script>
</head>
<body>
<form name="test" method="POST" action="test.php">
<div>
<b>Order Details:</b><input type="Text" name="order_details" Size="60" onBlur=addCheck()><br><br></div>
<div class="errormessage" id="somename"></div>
<div>
<b>Order Details:</b><input type="Text" name="order_details1" Size="60" onBlur=addCheck1()><br><br>
</div>
<div id="Layer1" style="position:absolute; left:90px; top:530px; width:315px; height:37px; z-index:1">
<input type="Submit" name="submit" value="Enter Information">
</div>
</form>
</body>
Most of this is doing what I want to do, however it is leaving the red bar across the page when information is entered.
I would be very grateful if someone could advise me on what to do next.