hi,
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..

1. function validate()
   2.  {
   3.     if (document.frm.id.value == "") {
   4.         alert("Enter Package Name");
   5.         document.frm.id.focus();
   6.         return (false);
   7.     }
   8.     chkId = /^[WAP_]{4}\d{2}$/;
   9.     if (chkId.test(document.frm.id.value)) {
  10.     } else {
  11.         alert('Invalid \"Pack Name\" Entry');
  12.         return false;
  13.     }
  14.     if (document.frm.act.value == "") {
  15.         alert("Enter Activation Status");
  16.         document.frm.act.focus();
  17.         return (false);
  18.     }
  19.     chkAct = /^[MA]{2}\d{2}$/;
  20.     if (chkAct.test(document.frm.act.value)) {
  21.     } else {
  22.         alert('Invalid \"Activation Status\" Entry');
  23.         return false;
  24.     }
  25.     return true;
  26. }
  27. function trim(stringToTrim) {
  28.     return stringToTrim.replace(/^\s+|\s+$/g, "");
  29. }
  30. var xmlHttp = null;
  31. function login() {
  32.     if (validate()) {
  33.  
  34.         try {
  35.             // Firefox, Opera 8.0+, Safari
  36.             xmlHttp = new XMLHttpRequest();
  37.         } catch (e) {
  38.             // Internet Explorer
  39.             try {
  40.                 xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  41.             } catch (e) {
  42.                 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  43.             }
  44.         }
  45.         var id = document.getElementById("id").value;
  46.         var url = "/xmlgprs/login.xml";
  47.         url = url + "?id=" + id;
  48.         xmlHttp.onreadystatechange = stateChanged;
  49.         xmlHttp.open("GET", url, true);
  50.         xmlHttp.send(null);
  51.     }
  52. }
  53. function stateChanged() {
  54.     if (xmlHttp.readyState == 4) {
  55.         if (xmlHttp.status == 200) {
  56.             parseMsg();
  57.         } else {
  58.             alert("Unable to retrieve");
  59.         }
  60.     }
  61. }
  62. function trim(stringToTrim) {
  63.     return stringToTrim.replace(/^\s+|\s+$/g, "");
  64. }
  65. function parseMsg() {
  66.     var id = document.getElementById("id").value;
  67.     response = xmlHttp.responseXML.documentElement;
  68.     var node = response.getElementsByTagName("PACK_NAME");
  69.     for ( var i = 0; i < node.length; i++) {
  70.         var node1 = node.item(i);
  71.         var childNodes = node1.childNodes;
  72.         for ( var j = 0; j < childNodes.length; j++) {
  73.             var childNode = childNodes.item(j);
  74.             if (childNode.nodeType == Node.TEXT_NODE) {
  75.                 //alert(childNode.nodeValue);
  76.                 if ( childNode.nodeValue == id) {
  77.                     alert("Pack Already Exists");
  78.                     return true;
  79.                 }
  80.             }
  81.         }
  82.     }
  83.     document.frm.submit();
  84. }
  85.  
  86.

Thanks..
madhu.

What is the element with id='id'?
Exactly what characters does it contain?
Is id='id' unique within the document?
Exactly what characters are in the childNode.nodeValue that you think should match the id?

Note: using the same value for a variable name and for an id (the string 'id' in this case) can cause problems in IE. And from a human standpoint, using variable names that look like reserved words [childNodes,childNode] - even where it works - does not make your code any easier to follow.

hi,
The id takes the 'String value' what i'll enter in the txt field...

I await with interest your answers to my four questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.