function checkFields(FormObj, fnames, ftypes, mins, maxs, errors, invalidchars, reqd) { var len = fnames.length; var errorList = new Array(); var errorIndex = new Array(); var errorOccured = false; var index = 0; for (i=0; i 0) { var handle = window.open("", "ewin","location=no,menubar=no,width=400,height=400,status=no,toolbar=no,resizable=yes"); var doc = handle.document; doc.write(" Errores de forma. "); doc.write("

HabĂ­a errores en la forma.

"); for (var j=0; j< errorList.length; j++) { doc.writeln("
" + errorList[j] + ""); } doc.close(); handle.focus(); return false; } if (handle!=null) { handle.close(); } return true; } function validString(stringval, min, max, invalidchars) { var i = 0; for (i=0; i< invalidchars.length; i++) { if (stringval.indexOf(invalidchars.charAt(i)) != -1) { return false; } } minlen = parseInt(min); maxlen = parseInt(max); return ((stringval.length >= minlen) && (stringval.length <= maxlen)); } function validInteger(stringval, min, max) { if (isDigits(stringval)) { return isInRangeInt(stringval, parseInt(min), parseInt(max)); } else { return false; } } function validFloat(stringval, min, max) { if (isNumber(stringval)) { return isInRangeFloat(stringval, parseFloat(min), parseFloat(max)); } else { return false; } } function isDigits(str) { var ind; for (ind = 0; ind < str.length; ind++) { mychar = str.charAt(ind); if (mychar < '0' || mychar > '9') { return false; } } return true; } function isNumber(str) { numdecs = 0; for (ind = 0; ind < str.length; ind++) { mychar = str.charAt(ind); if ((mychar >= '0' && mychar <= '9') || mychar == '.') { if (mychar == '.') { numdecs++; } } else { return false; } } if (numdecs > 1) { return false; } return true; } function isInRangeInt(str, num1, num2) { var intG = parseInt(str); return ((intG >= num1) && (intG <= num2)); } function isInRangeFloat(str, num1, num2) { var intF = parseFloat(str); return ((intF >= num1) && (intF <= num2)); } function openWin(helptext) { var handle = window.open("", "ewin1","location=no,menubar=no,width=400,height=300,status=no,toolbar=no,resizable=yes"); var doc = handle.document; doc.write(" Ayuda "); doc.write(helptext); doc.close(); handle.focus(); } function validEmail(emailStr) { var checkTLD=1; var emailPat=/^(.+)@(.+)$/; /* The following string represents the pattern for matching all special characters. We don't want to allow special characters in the address. These characters include ( ) < > @ , ; : \ " . [ ] */ var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; /* The following string represents the range of characters allowed in a username or domainname. It really states which chars aren't allowed.*/ var validChars="\[^\\s" + specialChars + "\]"; /* The following pattern applies if the "user" is a quoted string (in which case, there are no rules about which characters are allowed and which aren't; anything goes). E.g. "jiminy cricket"@disney.com is a legal e-mail address. */ var quotedUser="(\"[^\"]*\")"; /* The following pattern applies for domains that are IP addresses, rather than symbolic names. E.g. joe@[123.124.233.4] is a legal e-mail address. NOTE: The square brackets are required. */ var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; /* The following string represents an atom (basically a series of non-special characters.) */ var atom=validChars + '+'; /* The following string represents one word in the typical username. For example, in john.doe@somewhere.com, john and doe are words. Basically, a word is either an atom or quoted string. */ var word="(" + atom + "|" + quotedUser + ")"; // The following pattern describes the structure of the user var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); /* The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above. */ var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); /* Finally, let's start trying to figure out if the supplied address is valid. */ /* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */ var matchArray=emailStr.match(emailPat); if (matchArray==null) { /* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */ //alert("Email address seems incorrect (check @ and .'s)"); return false; } var user=matchArray[1]; var domain=matchArray[2]; // Start by checking that only basic ASCII characters are in the strings (0-127). for (i=0; i127) { //alert("Ths username contains invalid characters."); return false; } } for (i=0; i127) { //alert("Ths domain name contains invalid characters."); return false; } } // See if "user" is valid if (user.match(userPat)==null) { // user is not valid //alert("The username doesn't seem to be valid."); return false; } /* if the e-mail address is at an IP address (as opposed to a symbolic host name) make sure the IP address is valid. */ var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { // this is an IP address for (var i=1;i<=4;i++) { if (IPArray[i]>255) { //alert("Destination IP address is invalid!"); return false; } } return true; } // Domain is symbolic name. Check if it's valid. var atomPat=new RegExp("^" + atom + "$"); var domArr=domain.split("."); var len=domArr.length; for (i=0;i 255 || myArray[1] > 255 || myArray[2] > 255 || myArray[3] > 255) return false; if (myArray[0] == 0 && myArray[1] == 0 && myArray[2] == 0 && myArray[3] == 0) return false; return true; } else return false; } function displayStatusMsg(msgStr) { status=msgStr; document.MM_returnValue = true; } function getCookie(name) { if (document.cookie) { var tCookie = document.cookie; var index = tCookie.indexOf(name + "="); if (index == -1) return null; index = tCookie.indexOf("=", index) + 1; var endstr = tCookie.indexOf(";", index); if (endstr == -1) endstr = tCookie.length; return unescape(tCookie.substring(index, endstr)); } else { return ""; } } function setCookie(name, value) { var today = new Date(); var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // plus 28 days if (value != null && value != "") document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString(); }