var autofocussed = false; function validate_form(form) { "use strict"; autofocussed = false; var error = ""; var filter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegal = /[\(\)\<\>\,\;\:\\"\[\]]/ ; var tfld = ""; try { var field_contact_0 = form.elements["go_contactform_contact_field0"]; if (field_contact_0.value.length < 2 || field_contact_0.value === "") { error = error + "\n- Voer een naam in (minimaal 2 tekens)."; autofocus(field_contact_0); } } catch(e) { } try { var field_contact_1 = form.elements["go_contactform_contact_field1"]; if (field_contact_1.value.length < 6 || field_contact_1.value === "") { error = error + "\n- Voer een e-mailadres in (minimaal 6 tekens)."; autofocus(field_contact_1); }s = field_contact_1.value; tfld = s.replace(/^\s+|\s+$/, ""); if (field_contact_1.value !== "" && (!filter.test(tfld) || s.match(illegal))) { error = error + "\n- Voer een juist e-mailadres in."; autofocus(field_contact_1); } } catch(e) { } try { var field_contact_2 = form.elements["go_contactform_contact_field2"]; if (field_contact_2.value !== "" && field_contact_2.value.length < 10) { error = error + "\n- Voer een telefoonnummer in (minimaal 10 tekens) of laat dit veld leeg."; autofocus(field_contact_2); }if (field_contact_2.value !== "" && field_contact_2.value.replace(/[^0-9]/g, "").length < 10) { error = error + "\n- Voer een juist telefoonnummer in of laat dit veld leeg."; autofocus(field_contact_2); } } catch(e) { } try { var field_contact_3 = form.elements["go_contactform_contact_field3"]; if (field_contact_3.value.length < 3 || field_contact_3.value === "") { error = error + "\n- Voer een onderwerp in (minimaal 3 tekens)."; autofocus(field_contact_3); } } catch(e) { } try { var field_contact_4 = form.elements["go_contactform_contact_field4"]; if (field_contact_4.value.length < 10 || field_contact_4.value === "") { error = error + "\n- Voer een bericht in (minimaal 10 tekens)."; autofocus(field_contact_4); } } catch(e) { } //captcha (comment en contactformulier) try { var captcha = form.elements.captcha; if (captcha.value.length < 4 ) { error = error + "\n- Voer de code (4 tekens) in."; autofocus(captcha); } } catch(e) { } //comment (comment) try { var comment = form.elements.comment; if (comment.value.length < 5) { error = error + "\n- U kunt geen (bijna) lege reactie plaatsen."; autofocus(comment); } } catch(e) { } //email (comment) try { var email = form.elements.email; if (email.value.length < 5) { error = error + "\n- Voer uw e-mailadres in."; autofocus(email); } else { s = email.value; tfld = s.replace(/^\s+|\s+$/, ""); if (!filter.test(tfld) || s.match(illegal)) { error = error + "\n- Voer een correct e-mailadres in."; autofocus(email); } } } catch(e) { } //auteur (comment) try { var author = form.elements.author; if (author.value.length < 2) { error = error + "\n- Voer uw naam in."; autofocus(author); } } catch(e) { } //zoekopdracht (search) try { var search = form.elements.search; if (search.value.length < 3) { error = error + "\n- U kunt geen (bijna) lege zoekopdracht opgeven."; autofocus(search); } } catch(e) { } //toon errors (als die er zijn) if(error === "") { return true; } else { alert("U heeft niet alle velden juist en/of volledig ingevuld:" + error); return false; } } function autofocus(element_id) { "use strict"; if (autofocussed === false) { element_id.focus(); autofocussed = true; } }