Thank you very much jesh.It works just like the second set of code I've posted above.Except, it shows ALL error notes at once and hide as I type some in inputbox instead one at a time.What I've been looking for is that1. When user left required field(s) left blank, then highlight(for example: change color to lightyellow) the required field(s).Note: When required field is filled in change color back to "white"2. Instead of alret popup, error message will show right next to required field, one at a time start from the first required field and as it fills in.This error message box shold have "close" function. I assume that using CSS.3. Although it's highlighted ALL required fields, and show the error message at the first required field,user might be left first field and click the second(or any other required field) field, then show the error message for that field.Error message could be able to up and down as user click whichever required field.Basically, I'd like to add just like how Ajax "ValidatorCallout" works.At this point, this is the code and HTML and I'd like ADD fuctions above to it.Javascript;
function checkForm() {name = document.getElementById("name").value;email = document.getElementById("email").value;if (name == "") {hideAllErrors();document.getElementById("nameError").style.display = "inline";document.getElementById("name").select();document.getElementById("name").focus();return false;} else if (email == "") {hideAllErrors();document.getElementById("emailError").style.display = "inline";document.getElementById("email").select();document.getElementById("email").focus();return false;} return true;} function hideAllErrors() {document.getElementById("nameError").style.display = "none"document.getElementById("emailError").style.display = "none"}
HTML;
<form onSubmit="return checkForm();" method=post action="myscript.php"><span class=label>Name:</span><input type=text value="" id=name ><div class=error id=nameError>Required: Please enter your name<br></div><br><span class=label>Email:</span><input type=text value="" id=email ><div class=error id=emailError>Required: Please enter your email address<br></div><br><input type=submit value=Submit style="margin-left: 50px"></form>
PLESAE, PLEASE help!Thank you inadvance.