i tried to validate the data in XML file is present or not using the Ajax...here is the code...can anyone check it and provide me the solution...it is not validating the data..waiting for the reply...
Expand|Select|Wrap|Line Numbers
- function validate()
- {
- if (document.frm.id.value == "")
- {
- alert("Enter Package Name");
- document.frm.id.focus();
- return (false);
- }
- chkId=/^[WAP_]{4}\d{2}$/;
- if (chkId.test(document.frm.id.value))
- {}
- else
- {
- alert('Invalid \"Pack Name\" Entry');
- return false;
- }
- if (document.frm.act.value == "")
- {
- alert("Enter Activation Status");
- document.frm.act.focus();
- return (false);
- }
- chkAct=/^[MA]{2}\d{2}$/;
- if (chkAct.test(document.frm.act.value))
- {}
- else
- {
- alert('Invalid \"Activation Status\" Entry');
- return false;
- }
- if (document.frm.deact.value == "")
- {
- alert("Enter De-Activation Status");
- document.frm.deact.focus();
- return (false);
- }
- chkDeact=/^[MD]{2}\d{2}$/;
- if (chkDeact.test(document.frm.deact.value))
- {}
- else
- {
- alert('Invalid \"De-Activation Status\" Entry');
- return false;
- }
- if (document.frm.allwpp.selectedIndex < 0)
- {
- alert("Select one of the \"Allow Post-Paid or Not\" options.");
- document.frm.allwpp.focus();
- return (false);
- }
- if (document.frm.allwpp.selectedIndex == 0)
- {
- alert("Select \"Allow Post-Paid or Not\" option.");
- document.frm.allwpp.focus();
- return (false);
- }
- if (document.frm.shrt.value == "")
- {
- alert("Enter Package Name");
- document.frm.shrt.focus();
- return (false);
- }
- return true;
- }
- function trim(stringToTrim)
- {
- return stringToTrim.replace(/^\s+|\s+$/g,"");
- }
- function login()
- {
- if(validate())
- {
- xmlHttp=GetXmlHttpObject();
- if (window.XMLHttpRequest)
- {
- req = new XMLHttpRequest();
- }
- else if (window.ActiveXObject)
- {
- req = new ActiveXObject("Microsoft.XMLHTTP");
- }
- var id =document.getElementById("id").value;
- var url="/xmlgprs/login.xml";
- url=url+"?id="+id;
- xmlHttp.onreadystatechange=stateChanged;
- xmlHttp.open("GET",url,true);
- xmlHttp.send(null);
- }
- }
- function stateChanged()
- {
- if (req.readyState == 4)
- {
- if (req.status == 200)
- {
- parseMsg();
- }
- else
- {
- alert("Unable to retrieve");
- }
- }
- }
- function parseMsg()
- {
- response = req.responseXML.documentElement;
- var node = response.getElementsByTagName(id);
- var chkNode;
- var chkNode1 = chkNode.equals(node);
- idArray = new Array();
- for(var i=0;i<chkNode1;i++)
- {
- var node1 = node.item(i);
- idArray[i] = node1.text;
- }
- viewElement();
- }
- function viewElement()
- {
- alert("valid");
- }
madhu.