i had done validation in my program...it is validating and entering the values also...the problem is if i m giving the same value which is in XML file...it is taking not showing any error...can any one check my code and suggest me the solution..2day evening is submission of my work..i need help....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;
- }
- return true;
- }
- function trim(stringToTrim) {
- return stringToTrim.replace(/^\s+|\s+$/g, "");
- }
- var xmlHttp = null;
- function login() {
- if (validate()) {
- try {
- // Firefox, Opera 8.0+, Safari
- xmlHttp = new XMLHttpRequest();
- } catch (e) {
- // Internet Explorer
- try {
- xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- xmlHttp = 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 (xmlHttp.readyState == 4) {
- if (xmlHttp.status == 200) {
- parseMsg();
- } else {
- alert("Unable to retrieve");
- }
- }
- }
- function trim(stringToTrim) {
- return stringToTrim.replace(/^\s+|\s+$/g, "");
- }
- function parseMsg() {
- var id = document.getElementById("id").value;
- response = xmlHttp.responseXML.documentElement;
- var node = response.getElementsByTagName("PACK_NAME");
- for ( var i = 0; i < node.length; i++) {
- var node1 = node.item(i);
- var childNodes = node1.childNodes;
- for ( var j = 0; j < childNodes.length; j++) {
- var childNode = childNodes.item(j);
- if (childNode.nodeType == Node.TEXT_NODE) {
- //alert(childNode.nodeValue);
- if ( childNode.nodeValue == id) {
- alert("Pack Already Exists");
- return true;
- }
- }
- }
- }
- document.frm.submit();
- }
madhu..