I have updated the fiddle to remove the jquery dependency
function validateWieslid() {
var countnummer = document.getElementById("nummer").value.length;
var countpin = document.getElementById("pin").value.length;
if (countnummer < 6) {
document.getElementById("lrError").innerHTML = " Lidnummer moet 6 cijfers lang zijn.";
document.getElementById("lrError").style.backgroundColor = "red";
}
if (countpin < 4) {
document.getElementById("pinError").innerHTML = " Pin moet 4 cijfers lang zijn.";
document.getElementById("pinError").style.backgroundColor = "red";
}
}
BELOW IS NOW DEPRECATED:
There were a couple of issues with your code.
Here is a jsFiddle http://jsfiddle.net/SJJvk/
1) you were not triggering your function. 2) You were missing the # from your jQuery calling the error divs 3) your variables are actual numbers, no need to test for length,
function validateWieslid() {
var countnummer = $("#nummer").val().length;
var countpin = $("#pin").val().length;
console.log("cn is " + countnummer);
console.log("cn is " + countpin);
if (countnummer < 6) {
document.getElementById("lrError").innerHTML = " Lidnummer moet 6 cijfers lang zijn.";
document.getElementById("lrError").style.backgroundColor = "red";
}
if (countpin < 4) {
document.getElementById("pinError").innerHTML = " Pin moet 4 cijfers lang zijn.";
document.getElementById("pinError").style.backgroundColor = "red";
}
}