Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Ajax Ajax not working in jsp

Have Programming Question? Ask it here!
 
 
 


Devandra Sharma
Ajax not working in jsp
0 Answer(s)      2 years and 2 months ago
Posted in : Ajax


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%>


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Ajax not working in jsp
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...; frmMain.elements[i].valid; } } return blnValid; } //if Ajax
window.open() not working - Ajax
is that the pop up window is not at all working.. Once I click the button, the page
Advertisements
jsp & ajax
jsp & ajax  how to enable or disable textbox using radio buttons by using jsp and ajax? plz help me.... i m new in jsp & ajax
jsp and ajax
jsp and ajax  how to enable or disable textbox using radio buttons by using jsp and ajax
ajax jsp - Ajax
ajax 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
Ajax with jsp - Ajax
Ajax 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
using jsp's....and ajax - Ajax
using 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 - Ajax
jsp  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 - Ajax
ajax 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 - Ajax
ajax 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 AJAX very urgent - Ajax
JSP 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 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
Jsp 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
Jsp 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
Jsp 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
ajax in jsp
ajax 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 jsp
ajax 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
jsp and ajax - JSP-Servlet
jsp 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
JSP and AJAX- very urgent - Ajax
JSP 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
why jsp pages are not working on linux but java application is working in windows - JSP-Servlet
why jsp pages are not working on linux but java application is working in windows  java web application jsp pages are not showing the fileds corectly on linux server but same application is working on windows.why
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
Selection With Ajax and JSP
Selection 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
Servlet signup still not working satisfactorialy - JSP-Servlet
Servlet signup still not working satisfactorialy  Hello sir thanks for your reply I tried following code given by you, What it has a problem as: I tested it by empty values and it printed the else option i.e One
ajax code for jsp
ajax 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
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 - Ajax
Ajac 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-Servlet
ajax 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 validation - JSP-Servlet
Ajax 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
Ajax - JSP-Servlet
Ajax  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
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
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
refresh jsp page - Ajax
refresh jsp page  Code for refresh a web page in jsp.  Hi friend, function refreshpage() { window.location.reload
Ajax using jsp
Ajax 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 jsp
ajax using jsp  <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.StringTokenizer" %> <%@ page import="java.lang.*" %> <
datagid with paging using jsp - Ajax
datagid 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
DropDown in ajax+jsp
DropDown 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
application using AJAX and JQuery and also use JSP
application using AJAX and JQuery and also use JSP   i need create an application using AJAX and JQuery and also use JSP
Ajax
Ajax  how to impliment ajax in registration table using jsp-servlet
JSP Ajax Form
Ajax 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
Ajax
Ajax  how to include ajax in jsp page?   Hi, Please read Ajax First Example - Print Date and Time example. Instead of using PHP you can write your code in JSP. Thanks
how to implement ajax in struts2 to operate on selectbox in jsp
how to implement ajax in struts2 to operate on selectbox in jsp  I am doing a project on struts2 in which i have a jsp page which has 2 select boxes... the ajax wll be called and retrieve me the blocks under the selected district
Ajax with java(using Dojo) - JSP-Servlet
Ajax 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
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
Ajax Learner - Ajax
Ajax Learner  Hi, This is Ziaul,I am working as Java/j2ee Developer from last one year. i have to use Ajax for my current project.pls guide me how.../ajax/ http://www.roseindia.net/jsp/comboSelect.shtml Thanks
Ajax Learner - Ajax
Ajax Learner  Hi, This is Ziaul,I am working as Java/j2ee Developer from last one year. i have to use Ajax for my current project.pls guide me how should i proceed to learn Ajax. Thanks and Regards Ziaul Hauqe Siddique 
Ajax
Ajax  How to learn AJAX
ajax
ajax  please describe the ajax
ajax
me reg this. thanks KK   Combobox box using Ajax in JSP   i...ajax  HI, In my application using ajax if i type a managername in the textbox it should display all the employees under the that manager
access image from ajax store in mysql using jsp
access image from ajax store in mysql using jsp  access image from ajax store in mysql using jsp (code to access image captured by camera and store in mysql
Create Listbox in JSP using AJAX control
Create 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
 

 

 

DMCA.com