// validator © Jan Andersen - frontGATE Solutions ApS /* Use input alt property as input type for regexp Add id to all form elements Use input title property as error help text */ var text = /(\w+)/i; var date = /\d{1,2}-\d{1,2}-\d{4,4}/; var rx_search = /(\w+)/i; var subject = /(\w+)/i; var name = /(\w+)\s(\w+)/i; var address = /(\w+)/i; var company = /(\w+)/i; var postnr = /^\d{4}/; var city = /(\w+)/i; var phone = /^\d{8}/; var cvr = /^\d{8}/; var ean = /^\d{13}/; var integer = /(\d+)/; var space = /(\s+)/i; var email_syntax_invalidated = /([\_|\-|\.|\@])([\_|\-|\.|\@])/i; var email_syntax_valid = /^([a-z0-9])([a-z0-9|\_|\-|\.])*([a-z0-9])(\@){1,1}([a-z0-9])([a-z0-9|\_|\-|\.])*([a-z0-9])(\.)(([a-z]){2,3}|aero|arpa|asia|coop|info|jobs|mobi|museum|name|travel)$/i; var rx_password = /(\w+)/; var anychar = /(.+)/; var currency_syntax0 = /(\d+)/; var currency_syntax1 = /(\d+)\,\d{2}/; var currency_syntax2 = /[kr](\s)(\d+)\,\d{2}/; var pValue = ''; function pExists(obj, property) { for (var i in obj) { if ('' + i == property) { pValue = '' + obj[i]; return '' + obj[i]; } } pValue = ''; return ''; } function clsEmail() { this.test=_vmail; } function _vmail(value) { with (this) { if (!email_syntax_valid.test(value)) return false else { if (!email_syntax_invalidated.test(value)) return true; else return false; } } } var email = new clsEmail(); function clsValuta() { this.test=_vvaluta; } function _vvaluta(value) { with (this) { var validated = false; if (currency_syntax0.test(value)) { validated = true; } if (currency_syntax1.test(value)) { validated = true; } if (currency_syntax2.test(value)) { validated = true; } return validated; } } var valuta = new clsValuta(); function clsPassword() { this.test=_vpassword } function _vpassword(value) { with (this) { var tstr = new String(value); if (tstr.length > 5 && tstr.length <= 50) { if (!rx_password.test(value)) return false; else return true; } } return false; } var password = new clsPassword(); function clsSearch() { this.test=_vsearch; } function _vsearch(value) { with (this) { if (!rx_search.test(value)) return false else { var sstr = new String(value); if (sstr.indexOf(" ") > 0) if (sstr.length>3) return true; if (sstr.length>2) return true; else return false; } } } var search = new clsSearch(); function validate_search(id) { if (document.getElementById(id)) { var obj = document.getElementById(id); if (!search.test(obj.value)) { obj.style.borderColor = 'red'; window.alert(obj.title); obj.focus(); return false; } } return true; } function nb_validate(form_name) { var ok = true; var doc = document.forms[form_name]; for (i=0;i