how to check the entered field exists are not in xml

hi,
i m new to this forum as well as new to xml…in my project…i need to develop an xml file…i created it using DOM…if i enter the values from front-end i.e i used jsp pages…it is taking the values and appending…if i enter the txtfield which is already exists it is also appending…but i need is it should throw an alert message…i.e.‘Field already exists’…i also done validations using javascript…can anyone help me out…its urgent waiting for the reply.

Thanks in advance,
rajee…

Where are you using webMethods in this complete process?

hi,
i had done the validation using Ajax…it is validating…the problem is it is not inserting the values in XML file…can i get suggestion…where is the problem…here is the code…waiting for the reply…

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

function[/b][/color][/size][/COLOR][/SIZE] validate() {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (document.frm.id.value == “”) {
alert(
“Enter Package Name”);
document.frm.id.focus();
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] ([SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE]);
}
chkId =
/^[WAP_]{4}\d{2}$/;
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (chkId.test(document.frm.id.value)) {
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/color][/size][/COLOR][/SIZE] {
alert(
‘Invalid “Pack Name” Entry’);
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE];
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (document.frm.act.value == “”) {
alert(
“Enter Activation Status”);
document.frm.act.focus();
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] ([SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE]);
}
chkAct =
/^[MA]{2}\d{2}$/;
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (chkAct.test(document.frm.act.value)) {
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/color][/size][/COLOR][/SIZE] {
alert(
‘Invalid “Activation Status” Entry’);
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE];
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (document.frm.deact.value == “”) {
alert(
“Enter De-Activation Status”);
document.frm.deact.focus();
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] ([SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE]);
}
chkDeact =
/^[MD]{2}\d{2}$/;
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (chkDeact.test(document.frm.deact.value)) {
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/color][/size][/COLOR][/SIZE] {
alert(
‘Invalid “De-Activation Status” Entry’);
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE];
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (document.frm.allwpp.selectedIndex < 0) {
alert(
“Select one of the “Allow Post-Paid or Not” options.”);
document.frm.allwpp.focus();
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] ([SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE]);
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (document.frm.allwpp.selectedIndex == 0) {
alert(
“Select “Allow Post-Paid or Not” option.”);
document.frm.allwpp.focus();
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] ([SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE]);
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (document.frm.shrt.value == “”) {
alert(
“Enter Package Name”);
document.frm.shrt.focus();
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] ([SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE]);
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/color][/size][/COLOR][/SIZE][SIZE=2];
}

[/size][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

function[/b][/color][/size][/COLOR][/SIZE] trim(stringToTrim) {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] stringToTrim.replace(/^\s+|\s+$/g, “”[SIZE=2]);
}

[/size][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

var[/b][/color][/size][/COLOR][/SIZE] xmlHttp = [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/color][/size][/COLOR][/SIZE][SIZE=2];

[/size][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

function[/b][/color][/size][/COLOR][/SIZE] login() {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE][SIZE=2] (validate()) {

[/size][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/color][/size][/COLOR][/SIZE] {
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Firefox, Opera 8.0+, [U]Safari

[/u][/color][/size][/COLOR][/SIZE][SIZE=2]

xmlHttp = [/size][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/color][/size][/COLOR][/SIZE] XMLHttpRequest();
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/color][/size][/COLOR][/SIZE] (e) {
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Internet Explorer

[/color][/size][/COLOR][/SIZE][SIZE=2]

[/size][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/color][/size][/COLOR][/SIZE] {
xmlHttp =
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/color][/size][/COLOR][/SIZE] ActiveXObject(“Msxml2.XMLHTTP”);
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/color][/size][/COLOR][/SIZE] (e) {
xmlHttp =
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/color][/size][/COLOR][/SIZE] ActiveXObject(“Microsoft.XMLHTTP”);
}
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] id = document.getElementById(“id”).value;
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] url = “/xmlgprs/login.xml”;
url = url +
“?id=” + id;
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open(
“GET”, url, [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/color][/size][/COLOR][/SIZE]);
xmlHttp.send(
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/color][/size][/COLOR][/SIZE][SIZE=2]);
}
}

[/size][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

function[/b][/color][/size][/COLOR][/SIZE] stateChanged() {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (xmlHttp.readyState == 4) {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (xmlHttp.status == 200) {
parseMsg();
}
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/color][/size][/COLOR][/SIZE] {
alert(
“Unable to retrieve”[SIZE=2]);
}
}
}

[/size][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

function[/b][/color][/size][/COLOR][/SIZE] trim(stringToTrim)
{
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/color][/size][/COLOR][/SIZE] stringToTrim.replace(/^\s+|\s+$/g,""[SIZE=2]);
}

[/size][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

function[/b][/color][/size][/COLOR][/SIZE] parseMsg() {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] id = document.getElementById(“id”).value;
response = xmlHttp.responseXML.documentElement;
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] node = response.getElementsByTagName(“PACK_NAME”);
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//Na=Node();

[/color][/size][/COLOR][/SIZE][SIZE=2]

[/size][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//Na.toString()

[/color][/size][/COLOR][/SIZE][SIZE=2]

[/size][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// alert(node.length)

[/color][/size][/COLOR][/SIZE][SIZE=2]

[/size][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//ele=Element()

[/color][/size][/COLOR][/SIZE][SIZE=2]

[/size][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//ele.nodeValue

[/color][/size][/COLOR][/SIZE][SIZE=2]

[/size][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/color][/size][/COLOR][/SIZE] ( [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] i = 0; i < node.length; i++) {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] node1 = node.item(i);
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] childNodes=node1.childNodes;
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/color][/size][/COLOR][/SIZE] ( [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] j = 0; j < childNodes.length; j++) {
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]var[/color][/size][/COLOR][/SIZE] childNode=childNodes.item(j);
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE](childNode.nodeType == Node.TEXT_NODE){
alert(childNode.nodeValue);
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE](trim(childNode.nodeValue) == trim(id)){
alert(
“already Present”);
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/color][/size][/COLOR][/SIZE][SIZE=2];
}
}
}

[/size][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//idArray[i] = node1.text;

[/color][/size][/COLOR][/SIZE][SIZE=2]

}

}

Thanks in advance,
rajee.

[/size]