Javascript Example
Screen shot
Javascript form validation with border color

<html>
<head>
<title>Javascript Form Validation Without alert</title>
<script language="javascript">
function validate()
{
var str=true;
document.getElementById("username").style.borderColor = '';
document.getElementById("password").style.borderColor = '';


if(document.frm.username.value=='')
{
document.getElementById("username").style.borderColor = 'red';
str=false;
}

if(document.frm.password.value=='')
{
document.getElementById("password").style.borderColor = 'red';
str=false;
}

return str;
}
</script>
</head>
<body>
<form name="frm" action="" method="post" onSubmit="return validate()">
<table border="1" align="center">
<tr>
<td>User Name</td>
<td>
<input id="username" name="username" type="text" style="border-style:ridge;">
</td>
</tr>
<tr>
<td>Password</td>
<td>
<input id="password" name="password" type="password" style="border-style:ridge;">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="btnsubmit" type="submit" value="Login">
</td>
</tr>
</table>
</form>
</body>
</html>

You can download source code here