Hi I use the following form validation and it works all fine, except my email input does not get validated. Input type = email field name = emailto this is the code: function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("emailto","from", "emailfrom","zigi"); // Enter field description to appear in the dialog box var fieldDescription = Array("Friends E-mail","Friends Name", "Your E-mail","Your Name"); // dialog message var alertMsg = "These fields cannot be left blank:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "email": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } var strValue = emailto.obj.value; var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i; if (!strFilter.test(strValue)) alertMsg = "wrong or incomplete email" + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } PHP: What am I missing in the email validation, please? Thank a lot
Also consider registerating at: http://www.dynamicdrive.com/forums/ Since they specialise, in javascript.