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



Home Answers Viewqa Ajax Ajax not working in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Devandra Sharma
Ajax not working in jsp
0 Answer(s)      2 years and 7 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
JQuery-JSP AJAX example not working
JQuery-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
window.open() not working - Ajax
is that the pop up window is not at all working.. Once I click the button, the page
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. login.jsp: print("<html> <head> <meta http-equiv="Content-Type" content="text
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
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
jsp+ajax validation
jsp+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
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
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
 

 

 

DMCA.com