473,503 Members | 12,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validation fails in Chrome

17 New Member
I apologies first yesterday i was in a hurry to complete the task ... My problem is javascript validation is working fine in IE and firefox but the validation is not working in chrome. Here is the validation code.

validation.js
=============
Expand|Select|Wrap|Line Numbers
  1. function validate_required(field,alerttxt){with (field){if (value==null||value==""){alert(alerttxt);return false;}else{return true;}}}
  2.  
  3.  
  4.  
  5. function validate_phone(field,alerttxt)
  6. {
  7.     with (field)
  8.     {
  9.         var reg=/^\d{8,13}$/;
  10.         var phone = value;
  11.         if(phone!=null&&phone!="")
  12.         {
  13.             if(reg.test(phone) == false)
  14.             {
  15.                 alert(alerttxt);
  16.                 return false;
  17.                 }
  18.                 }
  19.                 else
  20.                 {
  21.                     return true;
  22.                     }
  23.                     }
  24.                     }
  25.  
  26.  
  27.                     function validate_age(field,alerttxt)
  28. {
  29.     with (field)
  30.     {
  31.         var reg=/^\d{2,2}$/;
  32.         var age = value;
  33.         if(age!=null&&age!="")
  34.         {
  35.             if(reg.test(age) == false)
  36.             {
  37.                 alert(alerttxt);
  38.                 return false;
  39.                 }
  40.                 }
  41.                 else
  42.                 {
  43.                     return true;
  44.                     }
  45.                     }
  46.                     }
  47.  
  48. function validate_salary(field,alerttxt)
  49. {
  50.     with (field)
  51.     {
  52.         var reg=/^\d{4,6}$/;
  53.         var salary = value;
  54.         if(salary!=null&&salary!="")
  55.         {
  56.             if(reg.test(salary) == false)
  57.             {
  58.                 alert(alerttxt);
  59.                 return false;
  60.                 }
  61.                 }
  62.                 else
  63.                 {
  64.                     return true;
  65.                     }
  66.                     }
  67.                     }
  68.  
  69.                     function validate_height(field,alerttxt)
  70. {
  71.     with (field)
  72.     {
  73.         var reg=/^\d{3,3}$/;
  74.         var height = value;
  75.         if(height!=null&&height!="")
  76.         {
  77.             if(reg.test(height) == false)
  78.             {
  79.                 alert(alerttxt);
  80.                 return false;
  81.                 }
  82.                 }
  83.                 else
  84.                 {
  85.                     return true;
  86.                     }
  87.                     }
  88.                     }
  89.  
  90.                     function validate_members(field,alerttxt)
  91. {
  92.     with (field)
  93.     {
  94.         var reg=/^\d{1,1}$/;
  95.         var members = value;
  96.         if(members!=null&&members!="")
  97.         {
  98.             if(reg.test(members) == false)
  99.             {
  100.                 alert(alerttxt);
  101.                 return false;
  102.                 }
  103.                 }
  104.                 else
  105.                 {
  106.                     return true;
  107.                     }
  108.                     }
  109.                     }
  110.  
  111.                     function validate_email(field,alerttxt){with (field){var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;var address = value;if(reg.test(address) == false) {alert(alerttxt);    return false;}else {return true;}}}
  112.  
  113.  
  114.  
  115.  
  116.  
  117. function validate_form(thisform)
  118. {
  119.  
  120.     with (thisform)
  121.     {
  122.         if (validate_required(name,"Name must be filled out!")==false)
  123.         {
  124.             name.focus();
  125.             return false;
  126.             }
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. /* if ((validate_required(age,"Age must be filled out!")==false) || (validate_age(age,"Not a valid age!")==false))  {age.focus();return false;}*/
  134.  if (validate_required(gender,"Gender must be filled out!")==false) {gender.focus();return false;}
  135.  /*if (validate_required(marriage,"Marriage must be filled out!")==false) {marriage.focus();return false;}*/
  136.  if (validate_required(dob,"Date of Birth must be filled out!")==false) {dob.focus();return false;}
  137.  if (validate_required(caste,"Caste must be filled out!")==false) {caste.focus();return false;}
  138.  if (validate_required(place,"Place must be filled out!")==false) {place.focus();return false;}
  139.  if (validate_required(rasi,"Rasi must be filled out!")==false) {rasi.focus();return false;}
  140.  if (validate_required(star,"Star must be filled out!")==false) {star.focus();return false;}
  141.  if (validate_required(height,"Height must be filled out!")==false) {height.focus();return false;}
  142.  if (validate_required(qualification,"Qualification must be filled out!")==false) {qualification.focus();return false;}
  143.  if (validate_required(profession,"Profession must be filled out!")==false) {profession.focus();return false;}
  144.  
  145.  if ((validate_required(income,"Monthly Income must be filled out!")==false)|| (validate_salary(income,"Not a valid income amount!")==false)) {income.focus();return false;}
  146.  if (validate_required(complexion,"Complexion must be filled out!")==false) {complexion.focus();return false;}
  147.  
  148.  if (validate_required(physique,"Physique must be filled out!")==false) {physique.focus();return false;}
  149.   if (validate_required(category,"Category must be filled out!")==false) {category.focus();return false;}
  150.   if ((validate_required(email,"Email must be filled out!")==false) || (validate_email(email,"Not a valid e-mail address!")==false))
  151. {email.focus();
  152.  
  153. return false;
  154. }
  155.   /*if (validate_required(pcreated,"Father Name must be filled out!")==false) {pcreated.focus();return false;}*/
  156.    if (validate_required(address,"Address must be filled out!")==false) {address.focus();return false;}
  157.     if ((validate_required(cell,"Cell Number must be filled out!")==false)|| (validate_phone(cell,"Not a valid cell number!")==false)) {cell.focus();return false;}
  158.      if (validate_required(native,"Native must be filled out!")==false) {native.focus();return false;}
  159.  if (validate_required(naddress,"Native address must be filled out!")==false) {naddress.focus();return false;}
  160.   if (validate_required(nphone,"Native Phone number must be filled out!")==false) {nphone.focus();return false;}
  161.  if (validate_required(family,"Family name must be filled out!")==false) {family.focus();return false;}
  162.  if (validate_required(fathername,"Father Name must be filled out!")==false) {fathername.focus();return false;}
  163.  if (validate_required(fprofession,"Father Profession must be filled out!")==false) {fprofession.focus();return false;}
  164.  if (validate_required(mothername,"Mother Name must be filled out!")==false) {mothername.focus();return false;}
  165.  if (validate_required(mprofession,"Mother Profession must be filled out!")==false) {mprofession.focus();return false;}
  166.  if (validate_required(rname1,"Relationship name must be filled out!")==false) {rname1.focus();return false;}
  167.  if (validate_required(raddr1,"Relationship address must be filled out!")==false) {raddr1.focus();return false;}
  168.   if (validate_required(rrel1,"Relationship must be filled out!")==false) {rrel1.focus();return false;}
  169.   if (validate_required(rname2,"Relationship name be filled out!")==false) {rname2.focus();return false;}
  170.  if (validate_required(raddr2,"Relationship address must be filled out!")==false) {raddr2.focus();return false;}
  171.       if (validate_required(rrel2,"Relationship must be filled out!")==false) {rrel2.focus();return false;}
  172.  
  173.  
  174.  
  175. }}
=======================

I think this code is for validating browser compatibility.
========
Expand|Select|Wrap|Line Numbers
  1. if (window.XMLHttpRequest)
  2.       {// code for IE7+, Firefox, Chrome, Opera, Safari
  3.       xmlhttp=new XMLHttpRequest();
  4.       }
  5.     else
  6.       {// code for IE6, IE5
  7.       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  8.       }
===============
I think the mistakes are in above code. Kindly help me to solve...

Regards

Zabi
Jan 20 '11 #1
1 1878
JKing
1,206 Recognized Expert Top Contributor
Line 158 is where the problem is. You have a variable "native" but native is a keyword in javascript.

Change the variable name to something else and you should be fine.
Jan 20 '11 #2

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

Similar topics

1
1670
by: ben | last post by:
When running the code below the validation fails when the first line of my xml contains <legalEnvelope version="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
5
3058
by: Helen | last post by:
Hi I'm using ASP.NET's standard validators to display error messages when people don't fill in required fields on my form. The error messages currently show as soon as the form is loaded, but...
2
2516
by: Walter | last post by:
I have a GridView using Template columns. In my EditItemTemplate I am using CompareValidators to check data types. When validation fails, I would like to change the border of the textbox in...
8
2256
by: SL | last post by:
I try to validate against a schema a document stored in several files thanks to external entities. The parseur add a 'xml:base="url"' attribute on the root element of this sub-trees during parsing,...
4
997
by: Morten Snedker | last post by:
http://test.planprojekt.dk/vaerk.aspx (http://validator.w3.org/check?uri=http%3A%2F%2Ftest.planprojekt.dk%2Fvaerk.aspx) fails validation. It fails due to tags not being closed properly. However,...
2
2040
by: turboJeeper | last post by:
I have a form with 16 fields, 10 of which use the RequiredFieldValidator controls. I want to display a custom message when the validation fails. However, all the validators have ClientScript...
1
5547
by: Artie | last post by:
Hi, Is there any way to tell an XSD Schema that you want custom error codes for particular validation failures in an XML document? To show what I mean, here's an example: XSD excerpt ...
1
3119
by: Artie | last post by:
Hi, Is there any way to tell an XSD Schema that you want custom error codes for particular validation failures in an XML document? To show what I mean, here's an example: XSD excerpt: ...
7
11311
pradeepjain
by: pradeepjain | last post by:
hii. i am developing a new form for which validation is done using php , so the error text gets displayed also,I wanted to make a improvement for form. i.e can the textfield for which validation...
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.