Html vorm sisuliste atribuutidega
Allikas: Lambda
<html>
<head>
<script src="standard.js"></script>
<script>
function check() {
var res=true;
var restxt='';
var flds = document.getElementsByTagName('input');
var i;
for(i=0; i<flds.length; i++) {
if (flds[i].getAttribute('mustfill')=='yes') {
if (flds[i].value=='') {
var name;
name=flds[i].getAttribute('nicename');
//alert(name);
if (!name) name=flds[i].name;
restxt=restxt+'väli '+name+' täitmata!\n';
res=false;
flds[i].style.backgroundColor = '#FFAAAA'
}
}
}
if (!res) alert(restxt);
return res;
}
</script>
</head>
<body onload="standardOnload('katse');">
Algus
<p>
<form method="get" action="http://www.epl.ee"
onsubmit="return check();">
Eesnimi: <input type="text" name="eesnimi"
mustfill="yes" nicename="Eesnimi"><br>
Perenimi: <input type="text" name="perenimi"
mustfill="yes"><br>
Kuupäev: <input type="text" name="kuupaev"
datatype="date"><br>
Telefon: <input type="text" name="telefon"
mustfill="no"><br>
Staatus:
<select name="staatus">
<option>Aktiivne</option>
<option>Kustutatud</option>
</select><br>
<input type="submit" onsubmit="check()"></input>
</form>
<p>
Lõpp.
</body>
</html>