我有这个学校的任务来制作这个表格。如果必须填写*标记,则必须填写*标记必须填写它(必须是红色)。这就是全部。 不要对我很难。
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).on("ready", geladen);
function geladen(){
console.log("geladen");
// zodra een veld verlaten wordt moet gecontrolleerd worden
}
function controlleerVerplicht(event){
// controlleer of er niets is ingevuld
if ( $('input*').val().length < 1 ){
$("*").css("border", "2px solid red").next().text("Dit veld is verplicht");
}
else ($("*").css("border", "2px solid green").next().text("Het is succesvol gedaan"));
// en zet in dat geval de tekst "Dit veld is verplicht" in de span in dezelfde paragraaf
}
function checkAcceptatie(){
console.log("check acceptatie");
if ($("input:checked").length==1){
$(":submit").removeAttr("disabled");
}
}
</script>
</head>
<body>
<form action="formulierverwerker.php" method="post">
<fieldset>
<legend>
NAW
</legend>
<p>
<label for="naamveld">Naam: *</label>
<label for="dhr">
<input type="radio" name="gender" value="m" id="dhr" />
dhr. </label>
<label for="mevr">
<input type="radio" name="gender" value="f" id="mevr" />
mevr. </label>
<input type="text" name="name" id="naamveld" class="verplicht" />
<span> </span>
</p>
<p>
<label for="straatveld">Straat:</label>
<input type="text" name="street" id="straatveld" />
<label for="straatveld">Huisnummer: *</label>
<input type="text" name="huisnummer" id="huisnummerveld" class="verplicht" />
<span> </span>
</p>
<p>
<label for="postcodeveld">Postcode: * </label>
<input type="text" name="zip" class="verplicht" id="postcodeveld" />
<label for="stadveld">Stad:</label>
<input type="text" name="city" class="verplicht" id="stadveld" />
<span> </span>
</p>
</fieldset>
<fieldset>
<legend>
Contact
</legend>
<p>
<label for="emailveld">Email:
<input type="text" name="email" id="emailveld" />
</label>
</p>
<p>
<label for="telefoonveld">Telefoon:
<input type="text" name="phone" id="telefoonveld" />
</label>
</p>
<p>
<button name="action" value="send" type="submit" >
Verstuur
</button>
</p>
</fieldset>
</form>