/* Clean Form Validation was written from scratch by Marc Grabanski // http://marcgrabanski.com/code/clean-form-validation /* Under the Creative Commons Licence http://creativecommons.org/licenses/by/3.0/ Share or Remix it but please Attribute the authors. */ var cleanValidator = { init: function (settings) { this.settings = settings; this.form = document.getElementById(this.settings["formId"]); formInputs = this.form.getElementsByTagName("input"); // change color of inputs on focus for(i=0;i "+errorMsg+"\n"; //error += Nameinput+"\n"; inputField.style.background = this.settings["errorColors"][0]; inputField.style.border = "1px solid "+this.settings["errorColors"][1]; //document.getElementById('errores').className = 'contact_error'; //document.getElementById('errores').innerHTML = error; } else { inputField.style.background = this.settings["inputColors"][0]; inputField.style.border = '1px solid'; //document.getElementById('errores').className = ''; } } } } return error; }, printError: function (error) { //alert(error); } }; // returns true if the string is not empty function isRequired(str){ return (str == null) || (str.length == 0); } // returns true if the string is a valid email function isEmail(str){ if(isRequired(str)) return false; var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i return re.test(str); } // returns true if the string only contains characters 0-9 and is not null function isNumeric(str){ if(isRequired(str)) return false; var re = /[\D]/g if (re.test(str)) return false; return true; }