Code: Select all
<script type='text/Javascript'>
function validate($element, $min, $empty)
{
$element.style.backgroundColor = (($element.value.length < $min) ? 'red' : 'green');
}
</script>
<form action='register.php' method='POST'>
<table border='0' cellspacing='0' cellpadding='2'>
<tr><td>Username:</td><td><input onkeyup="validate(this, 4, 0);" type='text' name='username' maxlength='16' size='16'></td></tr>
<tr><td>Password:</td><td><input onkeyup="validate(this, 4, 0);" type='password' name='password' maxlength='16' size='16'></td></tr>
<tr><td>E-mail:</td><td><input onkeyup="validate(this, 6, 0)" type='email' name='email' maxlength='32' size='16'></td></tr>
<tr><td></td><td><div style='border:1px solid #ff9933;padding:1px;width:58px;height:12px;'><input type='submit' name='submit' value='Register' class='submit' style='border:0px;margin-top:-1px;margin-bottom:-1px;'></div></td></tr>
</table>
</form>
Also... can anyone show me an example of how to retrieve the background color of certain input fields ( username, password, email ) after _POST to check if they are green and if so -> validation successfull... i've been trying to do that for the past 6 hours.... any1?