Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
- </head>
- <script>
- function checkUsername() {
- var request;
- try {
- request= new XMLHttpRequest();
- }
- catch (tryMicrosoft) {
- try {
- request= new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch (otherMicrosoft)
- {
- try {
- request= new ActiveXObject("Microsoft.XMLHTTP");
- }
- catch (failed) {
- request= null;
- }
- }
- }
- var url= "process.php";
- var user= document.getElementById("username").value;
- var pw= document.getElementById("password").value;
- var vars= "username="+user+"&password="+pw;
- request.open("POST", url, true);
- request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- request.onreadystatechange= function() {
- if (request.readyState == 4 && request.status == 200) {
- var return_data= request.responseText;
- document.getElementById("status").innerHTML= return_data;
- }
- }
- request.send(vars);
- }
- $(function () {
- $('#submit').click(function () {
- event.preventDefault();
- $.ajax({
- url: "submit.php",
- data: $('form').serialize(),
- type: "POST",
- success: function (result) {
- alert(result)
- }
- });
- });
- });
- </script>
- <form id="form" action="submit" method="POST">
- Enter a Username:
- <input type= "text" id="username" name="username" onblur="checkUsername()"/><label id="status"></label> <br> <br>
- Choose a Password:
- <input type= "password" id="password" name="password"/><br><br>
- <input type="submit" id="submit" name="submit" value="Submit"/>
- </form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement