Forum Moderators: open
I have an input tag like this:
Text2 <input type="text" name="txtfld2" value="" onfocusout="checkLength(this,3);" /> and here we have the checkLength() javascript function:
function checkLength(thisField,maxLength) {
alert(thisField);
if (thisField.length > maxLength) {
alert("Feltet kan ha maks " + maxLength + " tall");
thisField.style.backgroundColor='#ff0000';
ready = false;
} else { ready = true; }
}
Here are my other functions:
function checkIllegalChars(thisField) {
// check illegalChars
var legalChars = /[^\w¦,¦\.¦\/¦@]/;
if (legalChars.test(thisForm.txtfld.value)) {
alert("\nTillatte tegn er\nA-Å (store og små bokstaver)\n0-9 (tall)\n, (komma)\n. (punktum)\n_ (underscore)\n/ (skråstrek)\n@ (alfakrøl)");
thisField.style.backgroundColor='#ff0000';
ready = false;
} else { ready = true; }
}
function checkNumOnly(thisField) {
// check numbersOnly
if (/[^0-9]/.test(thisField.value)) {
alert("Kun tall");
thisField.style.backgroundColor='#ff0000';
ready = false;
} else { ready = true; }
}