Ajax not working in jsp
I'm using Netbean, Ajax validation in the following code is not working the code succesfully run for first UID validation adn also for ee-mail but does not enter if else for firstname field please help me out..
The files used are a zxml.js
A IncrementalFormValidation.js
function validateField(oEvent) {
oEvent = oEvent || window.event;
var txtField = oEvent.target || oEvent.srcElement;
var oXHR = zXmlHttp.createRequest();
oXHR.open("get", "ValidateForm.jsp?" + txtField.name + "=" + encodeURIComponent(txtField.value), true);
oXHR.onreadystatechange = function () {
if (oXHR.readyState == 4) {
if (oXHR.status == 200) {
var arrInfo = oXHR.responseText.split("||");
var imgError = document.getElementById("img" + txtField.id.substring(3) + "Error");
var btnSignUp = document.getElementById("btnSignUp");
if (!eval(arrInfo[0])) {
imgError.title = arrInfo[1];
imgError.style.display = "";
txtField.valid = false;
} else {
imgError.style.display = "none";
txtField.valid = true;
}
btnSignUp.disabled = !isFormValid();
} else {
alert("An error occurred while trying to contact the server.");
}
}
};
oXHR.send(null);
};
function isFormValid() {
var frmMain = document.forms[0];
var blnValid = true;
for (var i=0; i < frmMain.elements.length; i++) {
if (typeof frmMain.elements[i].valid == "boolean") {
blnValid = blnValid && frmMain.elements[i].valid;
}
}
return blnValid;
}
//if Ajax is enabled, disable the submit button and assign event handlers
window.onload = function () {
if (zXmlHttp.isSupported()) {
var btnSignUp = document.getElementById("btnSignUp");
var txtUID = document.getElementById("txtUID");
var txtFirstName = document.getElementById("txtFirstName");
var txtMiddlename = document.getElementById("txtMiddlename");
var txtLastname = document.getElementById("txtLastname");
var txtPhoneNo = document.getElementById("txtPhoneNo");
var txtEmailid = document.getElementById("txtEmailid");
var txtdobmonth = document.getElementById("txtdobmonth");
var txtdobday = document.getElementById("txtdobday");
var txtdobyear = document.getElementById("txtdobyear");
var txtselGender = document.getElementById("txtselGender");
var txtseloccupation = document.getElementById("txtseloccupation");
var txtYearlyIncome = document.getElementById("txtYearlyIncome");
var txtfile = document.getElementById("txtfile");
var txtAddress = document.getElementById("txtAddress");
var txtDistrict = document.getElementById("txtDistrict");
var txtfps = document.getElementById("txtfps");
btnSignUp.disabled = true;
txtUID.onblur = validateField;
txtFirstName.onblur = validateField;
txtMiddlename.onblur = validateField;
txtLastname.onblur = validateField;
txtPhone_No.onblur = validateField;
txtEmailid.onblur = validateField;
txtdob_month.onblur = validateField;
txtdob_day.onblur = validateField;
txtdob_year.onblur = validateField;
txtselGender.onblur = validateField;
txtseloccupation.onblur = validateField;
txtYearly_Income.onblur = validateField;
txtfile.onblur = validateField;
txtAddress.onblur = validateField;
txtDistrict.onblur = validateField;
txtfps.onblur = validateField;
txtUID.valid = false;
txtFirstName.valid=false;
txtMiddlename.valid=true;
txtLastname.valid=false;
txtPhone_No.valid =true;
txtEmailid.valid =true;
txtdob_month.valid=false;
txtdob_day.valid=false;
txtdob_year.valid=false;
txtselGender.valid=false;
txtseloccupation.valid=false;
txtYearly_Income.valid=true;
txtfile.valid=false;
txtAddress.valid=false;
txtDistrict.valid=false;
txtfps.valid=false;
}
};
And a validateForm.jsp
<%@page contentType="text/plain" pageEncoding="UTF-8" import="java.util.regex.*,java.text.DateFormat" %>
<%
//message output
String valid = "false";
String message = "An unknown error occurred.";
if (request.getParameter("txtUID")!= null){
if (request.getParameter("txtUID").length()==0){
message="This field cannot be blank";
}else{
String uid= request.getParameter("txtUID");
Pattern test =Pattern.compile ("[0-9]{12}$");
Matcher m=test.matcher(uid);
if (m.matches()){
valid = "true";
message = "";
} else {
message = "UID is 12 digits can only have numbers form 0-9";
}
}
} else if (request.getParameter("txtFirstName")!=null ){
String fname= request.getParameter("txtFirstName");
if(fname.length()==0){
message="This field cannot be blank";
}else {
Pattern t=Pattern.compile("[A-Za-z]$");
Matcher m1=t.matcher(request.getParameter("txtFirstName"));
if (m1.matches()){
valid="true";
message="";
}else{
message="First Name can only contain text value";
}
}
} else if (request.getParameter("txtMiddleName")!=null){
} else if (request.getParameter("txtLastName")!=null){
} else if (request.getParameter("txtPhone_No")!=null){
} else if (request.getParameter("txtEmailid") != null) {
if((request.getParameter("txtEmailid")).length()==0){
valid="true";
message="";
}else{
Pattern p = Pattern.compile("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$");
Matcher m = p.matcher(request.getParameter("txtEmailid"));
if (m.matches()){
valid = "true";
message = "";
} else {
message = "This e-mail address is not valid";
}
}
} else if (request.getParameter("txtdob_month")!=null){
} else if (request.getParameter("txtdob_day")!=null){
} else if (request.getParameter("txtdob_year")!=null){
} else if (request.getParameter("txtselGender")!=null){
} else if (request.getParameter("txtseloccupation")!=null){
} else if (request.getParameter("txtYearly_Income")!=null){
} else if (request.getParameter("txtfile")!=null){
} else if (request.getParameter("txtAddress")!=null){
} else if (request.getParameter("txtDistrict")!=null){
} else if (request.getParameter("txtfps") != null) {
}
%><%=valid%>||<%=message%>
View Answers
Related Tutorials/Questions & Answers:
Ajax not working in jspAjax not
working in jsp I'm using Netbean,
Ajax validation in the following code is not
working the code succesfully run for first UID validation...; frmMain.elements[i].valid;
}
}
return blnValid;
}
//if
Ajax JQuery-JSP AJAX example not workingJQuery-
JSP AJAX example not working Hi, I while back ran you... started with
AJAX)), I was able to get it
working. Just recently, I have been
working on some additional development code using
AJAX and I was getting some
Advertisements
jsp and ajaxjsp and ajax how to enable or disable textbox using radio buttons by using
jsp and
ajax jsp & ajaxjsp & ajax how to enable or disable textbox using radio buttons by using
jsp and
ajax?
plz help me.... i m new in
jsp &
ajax Ajax with jsp - AjaxAjax with jsp multiple combo boxes with
ajax in
jsp? Hi friend,
I am sending you a link. I hope that, this link will help you.
Please visit for more information.
http://www.roseindia.net/
jsp ajax jsp - Ajaxajax jsp multiple combo with
ajax using
jsp? Hi friend,
I am sending you a link. This link will help you. Please visit for more information.
http://www.roseindia.net/
jsp/comboSelect.shtml
Thanks
using jsp's....and ajax - Ajaxusing
jsp's....and ajax Hi,
i need code using
ajax .....in a text box when i enter an alphabet i should get list of words starts with the alphabet given in the text box
jsp - Ajaxjsp I'm very new in using the
jsp and
ajax,
i have some
JSP pages and i need to add some
ajax features in my
jsp
page,
for the example i need....
How can I implement this and then add this to my
jsp page?
please
ajax code with jsp - Ajaxajax code with jsp hi ,
Sorry for insufficient data.i m making some correction on question.
I have to perform some calculation on my
jsp page.
i want to do it automatically (using
ajax in
jsp).
problem is -
i hv two
ajax and jsp code - Ajaxajax and
jsp code can u please give me the code for retriving the data from database using
ajax
our requriment is
if i select country name in listbox display the corresponding all the states.
using
jsp and
ajax Jsp and ajaxJsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
Jsp and ajaxJsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
Jsp and ajaxJsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
Jsp and ajaxJsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
JSP and AJAX very urgent - AjaxJSP and
AJAX very urgent Hi Team,
This is Ragavendran.R.. I have a very basic doubt in
AJAX. While Using
AJAX, of course, there will be tag involved in
JSP page. But in my current project, I am using too many
tags
jsp and ajax - JSP-Servletjsp and ajax i had some problem
i want to display the current... to be automatically updated for every second
for that i want to make an
ajax call.../
jsp/fileupload.shtml
Thanks
ajax in jspajax in jsp i m not able to compare string with the responseText value, though the value in the responsetext is of string type.
my code:
login.jsp
<html>
<head>
<meta http-equiv
ajax in jspajax in jsp i m not able to compare string with the responseText value, though the value in the responsetext is of string type.
login.jsp:
print("<html>
<head>
<meta http-equiv="Content-Type" content="text
How to use ajax in jsp?How to use
ajax in
jsp? Hi,
How i can access the server-side data in
JSP using the
Ajax?
Thanks
Hi,
You can use the
Ajax code to access the server side data from
JSP page.
Check the tutorial Combo Box Using
Ajax JSP and AJAX- very urgent - AjaxJSP and
AJAX- very urgent Respected Sir/Madam,
I am... (Using
AJAX. for ur reference, I have included the coding below:
Login.html... not support
AJAX!");
return;
}
var url="check.jsp";
url=url+"?id="+alpha
jsp+ajax validationjsp+
ajax validation hi,
I have created the
jsp form (course... 60% in the drop down list .how to validate student from using
ajax and
jsp... have created student
jsp form where it should display register number
Selection With Ajax and JSPSelection With
Ajax and JSP I am
working at a
jsp page using
ajax for country , state, city selection.
so if he select country it will populate... the city.
I am doing it through two
jsp pages only.
Country1.jsp :
<%@ page
code for jsp - Ajax country.By using
jsp and
Ajax.
Hello Friend
I send the code you...code for jsp please give code for using
jsp page and Ajax.Retrive... getDetail(source,div){
getData(source,div);
}
An
Ajax Demo
Ajac code with jsp - AjaxAjac code with jsp hi ,
i am beginner for ajax.I have to perform some calculation on my
jsp page.
i want to do it automatically that is possible using
ajax.
problem is -
i hv two text box.
1st take
ajax in java - JSP-Servletajax in java The below code is for a php page but I want this in
JSP page.
function postRequest(strURL){
var xmlHttp...:
"login.php"
Hi friend,
Do some changes to convert in
JSP ajax code for jspajax code for jsp How to write
ajax code to retrieve information on to particular part of webpage when we select option from drop down box
The AJAX JSP Tag Library
The
AJAX JSP Tag Library
The
AJAX JSP Tag Library is a set of
JSP tags that
simplify the use of Asynchronous JavaScript and XML (
AJAX) technology in
JavaServer Pages. This tag
Ajax validation - JSP-ServletAjax validation How to fade out the images when an onblur function is called moving from a text box to another??
can anyone help out with with the code
refresh jsp page - Ajaxrefresh
jsp page Code for refresh a web page in
jsp. Hi friend,
function refreshpage()
{
window.location.reload
Ajax - JSP-ServletAjax Simple
ajax code for getting one text box value Hi friend,
Code to help in solving the problem :
function postRequest... on
Ajax visit to :
http://www.roseindia.net/
ajax/
Thanks
datagid with paging using jsp - Ajaxdatagid with paging using jsp datagrid with paging using
ajax and jsp Hi friend,
For read more information :
http://www.roseindia.net/
jsp/data-grid.shtml
Thanks
Ajax using jspAjax using jsp <%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import...);
}
%>
Is there Any error...........In first Page I use
ajax for displaying
ajax using jspajax using jsp <%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.StringTokenizer" %>
<%@ page import="java.lang.*" %>
<
DropDown and text boxes with AJAX, JSP - Ajax present.
we are already using
jsp's and java technology. can we integrate
ajax in
jsp's to achieve the same? if so could you please guide me to achive the same...DropDown and text boxes with
AJAX, JSP Hi,
we are using one drop
DropDown in ajax+jspDropDown in
ajax+jsp I have four dropdown if i select first dd then only corresponding values must be there in 2nd dd,same with 3 and 4 and onchangfe it would not refresh the whole page.
Hi Friend,
Try the following
Mutiple part is ot working - JSP-Servlet.
But in one system when i use enctype="mutlipart" its
working but in other system its not
working.
Is this a problem with the browser or nything else.../
jsp/file_upload/employee_upload_profile_image.shtml
Thanks
HI
AjaxAjax how to impliment
ajax in registration table using
jsp-servlet
Ajax with java(using Dojo) - JSP-ServletAjax with java (using Dojo) Hi, In In place Edit Box,when I click "save" button how can I save the data in server side i.e
JSP or how can I call.... Is there a possibility for tutorial on Scriptaculous. us,for Java programmers
JSP Ajax FormAjax Form Example
This example explains you how to develop a form that populates dynamically
from the database though
Ajax call.
When user selects employee id from the combo box then the corresponding
employee details are populated
Combo Box Using Ajax In JSP Combo Box Using
Ajax In
JSP
In this section, we develop an application to
Select the Data from database using
Ajax in combo box. We created two file
AjaxAjax how to include
ajax in
jsp page?
Hi,
Please read
Ajax First Example - Print Date and Time example.ADS_TO_REPLACE_1
Instead of using PHP you can write your code in
JSP.
Thanks
Create Listbox in JSP using AJAX controlCreate Listbox in
JSP using
AJAX control Hi everyone!!!
I want... listbox to select single elemnt using
AJAX control . But i don't know anything about
AJAX.
In that listbox,listbox items are dictly fetched from databases