Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
<!--
#t2 {
background-Color:#B8F5B1;
}
-->
</style>
<script type="text/javascript">
<!--
function fieldErrors(id,hex) {
var fld=document.getElementById(id),theBgd = zxcRGBtoHex(zxcSV(fld,'background-Color'));
if(theBgd != hex.toLowerCase()){
alert("Oops, there is an error with your\n"+fld.title);
return false;
}
}
function zxcSV(obj,par){
if (obj.currentStyle) return obj.currentStyle[par.replace(/-/g,'')];
return document.defaultView.getComputedStyle(obj,null).getPropertyValue(par.toLowerCase());
}
function zxcRGBtoHex(zxcrgb){
if (zxcrgb.charAt(0)=='#'){
return zxcrgb.toLowerCase();
}
if (zxcrgb.charAt(0)=='r'){
zxcrgb=zxcrgb.replace('rgb(','').replace(')','').split(',');
return '#'+zxcHex(zxcrgb[0])+zxcHex(zxcrgb[1])+zxcHex(zxcrgb[2]);
}
return '';
}
function zxcHex(zxcnu) {
if (zxcnu==null) return '00';
zxcnu=parseInt(zxcnu);
if (zxcnu==0||isNaN(zxcnu)) return '00';
zxcnu=Math.max(0,Math.min(zxcnu,255));
var zxchex='0123456789abcdef';
return zxchex.charAt((zxcnu-zxcnu%16)/16)+zxchex.charAt(zxcnu%16);
}
//-->
</script>
</head>
<body>
<input title="First Name Field" id="t1" name="">
<input title="Last Name Field" id="t2" name="">
<script type="text/javascript">
<!--
fieldErrors('t1','#B8F5B1');
fieldErrors('t2','#B8F5B1');
//-->
</script></body>
</html>
some browsers use hex some upper case some lower case some rgb for colors
Bookmarks