javascript - AJAX Message Clear -
i finishing form user registration, , wanted know how clear messages generated dynamically ajax, when user clears input (backspace). example, let's enter valid input, clear backspaces - code shows valid input message, want switch empty string / no message when happens:
if ($namecheckcount < 1) { if (preg_match("/^\w+@[a-za-z_]+?\.[a-za-z]{2,3}$/", $email)) { echo 'this email available.'; exit(); } else { echo 'you entered email invalid format.'; exit(); } } else { echo 'this email taken.'; exit(); }
is there way can change above code have clear message if there no input after backspace?
secondly, once input validated (i have 1 main html file form, , 3 php files check username, password, , email validity through use of mysql, or in case of passwords, simple string match), can set sort of flag allow user submit? example, code checks email such:
function checkemail() { "use strict"; var status = document.getelementbyid("email_status"); var email = document.getelementbyid("email").value; if (!(email == "")) { status.innerhtml = "checking..."; var request = new xmlhttprequest(); request.open("post", "email_check.php", true); request.setrequestheader("content-type", "application/x-www-form-urlencoded"); request.onreadystatechange = function() { if (request.readystate == 4 && request.status == 200) { status.innerhtml = request.responsetext; } } var verify = "emailtocheck=" + email; request.send(verify); } }
this within html file form. once fields validated, there way allow user submit? 1 user may have unique combination of username , email fields stored in user table along other data, , no username can associated multiple usernames, , vice versa. thank in advance tips!
Comments
Post a Comment