html login page with ajax

html login page with ajax

hi all... i want to create a login page using html and ajax for validation is must. please help me doing that with code...

thanks in advance

View Answers

September 4, 2012 at 3:39 PM

Here is a jsp example that accepts username and password from the user and check whether the user is valid or not by using ajax.

1)ajaxLogin.jsp

<html>
<head>
<script language="javascript">
function postRequest(strURL){
var xmlHttp;
if(window.XMLHttpRequest){ 
var xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){ 
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST', strURL, true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4){
updatepage(xmlHttp.responseText);
}
}
xmlHttp.send(strURL);
}

function updatepage(str){
if(str=="yes"){
alert("Welcome User");
}else{
alert("Invalid Login! Please try again!");
}
}

function call_login(){
var username = window.document.f1.username.value;
var password = window.document.f1.password.value;
var url = "check.jsp?username=" + username + "&password=" +password ;
postRequest(url);
} 
</script>
</head>

<body>
<Center>

<form name="f1" onsubmit="return call_login();">
<table border="0" bgcolor="#CCCCFF" cellspacing="1" cellpadding="3" width="287">
<tr>
<td align="left" colspan="2" width="275"><b><font size="5" color="#000080">Login</font></b></td>
</tr>
<tr>
<td align="right" width="81"><b><font color="#000080">User
Name:</font></b></td>
<td width="184"><input type="text" name="username" id="user" size="20" value="" /></td>
</tr>
<tr>
<td align="right" width="81"><b><font color="#000080">Password:</font></b></td>
<td width="184"><input type="password" name="password" size="20" value="" /></td>
</tr>
<tr>
<td colspan="2" align="center" width="275"><input type="button" name="a1" value="Login" onclick="call_login()"></td>
</tr>
</table>
</form>

</center>
</body>
</html>

2)check.jsp:

<%
String username=request.getParameter("username");
String password=request.getParameter("password");
if(username=="admin" && password=="admin"){
out.println("yes");
}else{
out.println("no");
}
%>









Related Tutorials/Questions & Answers:
html login page with ajax
html login page with ajax  hi all... i want to create a login page using html and ajax for validation is must. please help me doing that with code... and password from the user and check whether the user is valid or not by using ajax
HTML login page code
HTML login page code  Hi all, I am writing my first HTML JavaScrip... the complete HTML JavaScript code for User Login Page. Thanks in Advance!   ...;td colspan=2><font size=3><center><b>HTML Login Page
Advertisements
what is the code for login page in html
what is the code for login page in html  Hi, I am total beginner in HTML coding. I want to make a login page in HTML to understand the form coding... page in html? How to create login page in HTML? Thaks
what is the code for login page in html
what is the code for login page in html  Hi, I am total beginner in HTML coding. I want to make a login page in HTML to understand the form coding... page in html? How to create login page in HTML? Thaks
what is the code for login page in html
what is the code for login page in html  Hi, I am total beginner in HTML coding. I want to make a login page in HTML to understand the form coding... page in html? How to create login page in HTML? Thaks
HTML Login Page Code
HTML Login Page Code Here is an example of html login page code... on their credentials. For making login page for websites HTML form and HTML elements... But in this tutorial you will learn to create a login page in HTML and validate
using ajax and jsp (struts) to login and remain on same page.
using ajax and jsp (struts) to login and remain on same page.  I am a fresher... I can forward my login page to success page using struts, but I want to remain on same login page and just want to display loggers name ... I don't
How to create simple HTML Login Page?
Simple HTML Login Page- Create a Simple HTML Login page and validate... with JavaScript. You will  learn How to create a simple HTML login page... How to make Spring web Login form? HTML Login Page Code
How to create simple HTML Login Page?
Simple HTML Login Page- Create a Simple HTML Login page and validate... with JavaScript. You will  learn How to create a simple HTML login page...? HTML Login Page Code Spring 4 MVC Login form Example
HTML WITH AJAX
HTML WITH AJAX  I WANT A SIMPLE HTML AJAX PROGRAM WHICH GETS ANY STRING STRING AS INPUT AND GIVES THE RESULT
ajax login example
ajax login example  hi deepak, i am trying to execute ajax login example in eclipse but it show the form but when I enter admin admin it shows invalid credentials how to resolve
login page
login page  code for login page
Login page
Login page  how to create Login page in java
Find currenly which field is having focus on html page? - Ajax
Find currenly which field is having focus on html page?  Hi All, Actually I want to ask question about Javascript, but there is no any option in Category. My problem is I have two form on single html page with two different
facebook login button html
facebook login button html  facebook login button html i have a facebook login button code ..but not sure how to use it. Can any one please explain? Here is the facebook login button code in html <fb:login-button
Login Page
Login Page  Can anyone tell me the steps to create a login page in myeclipse 7.0 and validating it with login database in db2 9.7 ??? Please tell me
login page
login page  hi i'm trying to create login page using jsp. i get... the program. Following are my programs... 1.index.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> JSP Page
PHP/HTML/AJAX Question
PHP/HTML/AJAX Question  I have a PHP/HTML program that sends a parm to a .JS program using Ajax logic (onchange) and it returns it. It returns it as a HTML var but I need it as a PHP $var. How do I get it to into a $var and where
login page
login page  pls say how to create a login page in jsp and mysql using netbaens   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://roseindia.net/jsf/netbeans/index.shtml http://roseindia.net/jsp
login page
login page  How to login as different user in php
LOGIN PAGE
LOGIN PAGE  A java program with "login" as title,menus added, and a text field asking for firstname, lastname, and displaying current date and time
coding for login page
coding for login page  coding for login page
login page in php
login page in php  How to create a login page in php
Login Form using Ajax
Login Form using Ajax      ... using the Ajax (DOJO).  Lets develop a login application using Ajax...; </action> Develop a Login Form Using Ajax : The GUI
What is the use of Login Page?
simple HTML Login Page? In case native applications such as Android or iOS login... Form? How to create simple HTML Login Page? HTML Login Page Code HTML Code for registration form
login page code in asp.net
login page code in asp.net  i need front end and backend code for login page in vb asp.net using sql server....having code for submit button
jsp login page
jsp login page  hi tell me how to create a login page using jsp and servlet and not using bean... please tell how to create a database in sql server... please tell with code
SSL for login page
SSL for login page  I am trying to apply ssl cert to login page only. Does anyone know how to do this on a tomcat web server
login page error
login page error  How to configure in to config.xml .iam takin to one login form in that form action="/login" .when iam deployee the project... this request." please suggest me.   if your login page is prepared
Login through database with the help of jQuery 'ajax' & JSP
a login page , which has a JSP page to perform database connection. In this example , login page contain jQuery ajax to make connection with JSP ,which...Login through database with the help of jQuery 'ajax' & JSP
JSP LOGIN Page
JSP LOGIN Page  sir....i have two user types usercategory and user and both user have userid and password in two different table and now i am making login page for which i have to retrieve usertype,userid and password from two
login page with image
login page with image  I am writing program for login page.It consists of a image and the login details... how to write a java program using frames that have the default positions in any of the systems.. thanks   i had
Spring Login Page Error
Spring Login Page Error  Dear Sir/Madam, I used the spring login page code. The index page is working fine. When i try to entry login and password , i am getting the below error: Please help me out in this. Let me know if i
login page - Java Beginners
login page  I have one login page in jsp that is login.jsp. Now i have validate user from database by another page validate.jsp. but if the user feeded wrong information then i want to print error massege on the first page
jsp login page
jsp login page  Hi All, can any one tell me how to create Login page using JSP and Beans. A simple log in page. Please reply ASAP.ADS...:ADS_TO_REPLACE_2 JSP Login Using Bean Thanks   Hi,ADS_TO_REPLACE_3
filter and display html table data using ajax - Ajax
filter and display html table data using ajax  Hi i am stuck up at a situation where i have a jsp page from where the control goes to the .js file calling the ajax function called retrieveURL.from here goes
Login page validation on ipad
Login page validation on ipad  I am using userId & password labels and their corresponding textfield. Now I want to validate the details by single sign in button and want to switch on to next page. Used two labels again
simplest HTML page
simplest HTML page  What is the simplest HTML page
how to use ajax in html file
how to use ajax in html file  <!DOCTYPE html PUBLIC "-//W3C//DTD...; <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <..." /> <meta http-equiv="Content-Type" content="text/html; charset
login page validation
login page validation  hi could you please send me code for login validations Email validation and password email should be in correct format and valid password in java   import java.awt.*; import javax.swing.
login page with mysql using jsp
login page with mysql using jsp  pls i need a sample of login page to check username and password in mysql database. thanks
login page php mysql example
login page php mysql example  How to create a login page for user in PHP Mysql? Please provide me a complete tutorial. Thanks in Advance
JSP Login Page Question
JSP Login Page Question  hey..i have a login page where different users first registered and then after they can login. my question is how a user can see only his data after login where different users data are stored
login for different user in the same page
login for different user in the same page  how can i do the login for different user in the same page throug jsp
.Net and SQl 2000 Login page
.Net and SQl 2000 Login page  Please help me creating a login page using dot net using data base sql 2000
Populate value into HTML page
Populate value into HTML page  Hi, How to populate values from one html page table to another html page..? Thanks
divide html page
divide html page   how to divide html page into 3 parts without using frames
Ajax Login Program
Ajax Extensible Page
Ajax Extensible Page (AEP) The Ajax Extensible Page is the feature of Web 2.0, which transforms the Website building practices The Ajax Extensible Page... to Use Step1: Include extensible.js file in your web page. Step2: Place
page breaks in HTML
page breaks in HTML  How do I specify page breaks in HTML

Ads