questa funzione dovrebbe riconoscre la presenza di errori nel form e restituire messaggi di errore ma non succede nulla.Se mancano nel form valori come il nome o il contenuto si prosegue direttamente a scrivere sul DB che naturalmente da errore.codice:function CheckForm () { //Intialise variables var errorMsg = ""; var errorMsgLong = ""; //Check for a name if (document.frmSignGuestBook.name.value == ""){ errorMsg += "\n\tName \t\t- Enter your Name"; } //Check for a country if (document.frmSignGuestBook.country.value == "0"){ errorMsg += "\n\tCountry \t\t- Select the country you are in"; } //Check for comments if (document.frmSignGuestBook.comments.value == ""){ errorMsg += "\n\tComments \t- Enter a comment to add to the Guestbook"; } //Check the description length before submiting the form if (document.frmSignGuestBook.comments.value.length > <% = intMsgCharNo %>){ errorMsgLong += "\n- Your comments are " + document.frmSignGuestBook.comments.value.length + " chracters long, they need to be shortned to below <% = intMsgCharNo %> chracters."; } //Check the word length before submitting words = document.frmSignGuestBook.comments.value.split(' '); for (var loop = 0; loop <= words.length - 1; ++loop){ if (words[loop].length >= 50){ errorMsgLong += "\n- A word in your comments contains " + words[loop].length + " characters, this needs to be shortened to below 50 characters."; } } //Check for HTML tags before submitting the form for (var count = 0; count <= 7; ++count){ if ((document.frmSignGuestBook.elements[count].value.indexOf("<", 0) >= 0) && (document.frmSignGuestBook.elements[count].value.indexOf(">", 0) >= 0)){ errorMsgLong += "\n- HTML tags are not permitted, remove all HTML tags."; } } <% If blnSecurityImages Then %> //Check for comments if (document.frmSignGuestBook.securityCode.value == ""){ errorMsg += "\n\tSecurity Code \t- Enter the security code shown in image format"; }<% End If %> //If there is aproblem with the form then display an error if ((errorMsg != "") || (errorMsgLong != "")){ msg = "___________________________________________________________________\n\n"; msg += "Your Comments have not been added because there are problem(s) with the form.\n"; msg += "Please correct the problem(s) and re-submit the form.\n"; msg += "___________________________________________________________________\n\n"; msg += "The following field(s) need to be corrected: -\n"; errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong); return false; } return true; }
Cosa devo inserire/modificare per far si che in mancanza di nome o altri parametri venga resituito un messaggio di errore?considerate che cno asp sono a meno di 0
Grazie!