473,385 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

validating the entering field

149 100+
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..

Expand|Select|Wrap|Line Numbers
  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..
Jun 29 '10 #1
0 769

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brains | last post by:
hello, I am new to access .I am trying to validate a numeric field (Employee number)This field is not auto generated,it is user input field.The data entered in this field should not be less than...
3
by: news.shaw.net | last post by:
I have a subform that contains a currency field. If I tab my way to the field, everything works as desired, a number can be entered, and when I leave the field it is rendered as a currency...
2
by: JC Mugs | last post by:
I have a form that when you tab from field to field that the entry point is blank, but if you point and click in the field it brings up a 0 and data entry is started to the left of the zero. ...
2
by: Bogdan Zamfir | last post by:
Hi, When users TAB to a field, I want it not to select all field content, but instead go to either begin or end of the field. This because sometimes user TAB to a field then type something by...
1
by: Emmanuel | last post by:
Hi, I have a webform with some input controls in it. Some of these controls have validation controls assigned. So far so good. I would like to have a validator which validates a field only if...
1
by: viki.sanjeeva | last post by:
Hi, There is a date field in JSP form where user will enter date in dd-mm-yyyy format. Now before saving into DB2, I want to validate the date format against dd-mm-yyyy format and then save into...
4
by: AA Arens | last post by:
I use SetFocus to jump from one field to another. That works fine. But one of the focussed fields has default text and this text is selected and the cursor is on the left of it. How to have the...
5
by: RICHARD BROMBERG | last post by:
Using Access 2000. I have a form with about a dozen fields . As each field gets or loses focus I change the background color between white (lost focus) and yellow ( got focus). Makes a nice...
3
by: mistyqe | last post by:
I have 2 fields I need to validate in a form. One is a drop-down box with a few options. The second is a text box where the user can enter their own value. The way it should work is that either...
10
by: chandhseke | last post by:
I have developed a web page using ASP classic, I am using VBScript for database connectivity... The web application is working fine, but i am now working on a new enhancement requirement where i need...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.