/*************************************************************** * * Universal validate-form * * $Id: jsfunc.validateform.js,v 1.4 2004/04/19 15:25:53 typo3 Exp $ * * * * Copyright notice * * (c) 1998-2003 Kasper Skaarhoj * All rights reserved * * This script is part of the TYPO3 t3lib/ library provided by * Kasper Skaarhoj together with TYPO3 * * Released under GNU/GPL (see license file in tslib/) * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * This copyright notice MUST APPEAR in all copies of this script ***************************************************************/ function validateForm(theFormname,theFieldlist,goodMess,badMess,emailMess) { if (document[theFormname] && theFieldlist) { var index=1; var theField = split(theFieldlist, ",", index); var msg=""; var theEreg = ''; var theEregMsg = ''; var specialMode = ''; while (theField) { theEreg = ''; specialMode = ''; // Check special modes: if (theField == '_EREG') { // EREG mode: _EREG,[error msg],[JS ereg],[fieldname],[field Label] specialMode = theField; index++; theEregMsg = unescape(split(theFieldlist, ",", index)); index++; theEreg = unescape(split(theFieldlist, ",", index)); } else if (theField == '_EMAIL') { specialMode = theField; } // Get real field name if special mode has been set: if (specialMode) { index++; theField = split(theFieldlist, ",", index); } index++; theLabel = unescape(split(theFieldlist, ",", index)); theField = unescape(theField); if (document[theFormname][theField]) { var fObj = document[theFormname][theField]; var type=fObj.type; if (!fObj.type) { type="radio"; } var value=""; switch(type) { case "text": case "textarea": value = fObj.value; break; case "select-one": if (fObj.selectedIndex>=0) { value = fObj.options[fObj.selectedIndex].value; } break; case "select-multiple": var l=fObj.length; for (a=0;a