/*************************************************************** * * Universal validate-form * * * * * Copyright notice * * (c) 1998-2000 Kasper Skårhøj * All rights reserved * * This script is part of the standard PHP-code library provided by * Kasper Skårhøj, kasper@typo3.com * * 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) { if (document[theFormname] && theFieldlist) { var index=1; var theField = split(theFieldlist, ",", index); var msg=""; while (theField) { 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