473,383 Members | 1,859 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,383 software developers and data experts.

javascript conflict

229 100+
hi, I have two javascript form validation scripts.

Although the forms have different names, one of the scripts overrides the other and validates both. They have the same onsubmit, and one has a unique name (contact) and I cannot see why it is affecting the others search form which doesnt have a name.

Expand|Select|Wrap|Line Numbers
  1. onsubmit="return validate_form(this)"
the search validation is

Expand|Select|Wrap|Line Numbers
  1. function validate_required(field,alerttxt)
  2. {
  3. with (field)
  4. {
  5. if (value==null||value=="")
  6.   {alert(alerttxt);return false}
  7. else {return true}
  8. }
  9. }function validate_form(thisform)
  10. {
  11. with (thisform)
  12. {
  13. if (validate_required(SearchWord,"Please enter a value for the \"search word\" field!")==false)
  14.   {SearchWord.focus();return false}
  15. }
  16. }
and the form validation is

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. <!--
  4.  
  5. function validate_form ( )
  6. {
  7.     valid = true;
  8.  
  9.         if ( document.contact.ToName.value == "" )
  10.         {
  11.                 alert ( "Please fill in the 'Recipients Name." );
  12.                 valid = false;
  13.         }
  14.   if ( document.contact.ToEmail.value == "" )
  15.         {
  16.                 alert ( "Please fill in the 'Recipients Email' box." );
  17.                 valid = false;
  18.         }
  19.   if ( document.contact.FromName.value == "" )
  20.         {
  21.                 alert ( "Please fill in the 'Your Full Name' box." );
  22.                 valid = false;
  23.         }
  24.   if ( document.contact.FromEmail.value == "" )
  25.         {
  26.                 alert ( "Please fill in the 'Your Email' box." );
  27.                 valid = false;
  28.         }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.         return valid;
  35. }
  36.  
  37. //-->
  38.  
  39. </script>
They are the only two that seem to work back to IE5 that I can find.

How do I make them with unique so one does not override the other. At the moment the search validation comes up with enter the correct email,name,etc. It should just say enter a search term.
Any help would be greatly appreciated.


Thanks
Richard
Sep 30 '07 #1
1 2395
fran7
229 100+
Hi, I sorted it out. I just changed the function. They were identical on both scripts.
Thanks
Richard
Sep 30 '07 #2

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

Similar topics

10
by: Andrea | last post by:
Hi everyone, I am in the process of learning javascript and have a question on location.href. Does javascript always require the <script language = "javascript"> (or script...
1
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: ...
2
by: Slav | last post by:
Hello, I'm trying to put a menu on a page containing a select form. The code for the menu I took from http://dynamicdrive.com/dynamicindex1/topnavbar.htm and the form is in the code...
2
by: loquini | last post by:
Hi, I'm using this piece of code, both scripts work fine separately but together only works the second one, How can I solve this conflict??? plss help me <body> <div id="watermarklogo"...
0
by: Caesar Augustus | last post by:
I'm having a problem with two different javascript controls in my app. The first chuck of javascript that I pasted into my app is the client-side calendar control popup which works fine when first...
13
by: mudgen | last post by:
I have a webpage that has two flash animations running. I also have a javascript script running that rotates 3 images and fades them in and out. To do the fading and rotating in javascript I am...
14
Webwench
by: Webwench | last post by:
I am trying to run a simple script- (I'm just learning javascrpt) that uses a set of buttons to change the background and foreground colors of a web page. Some of the text on the page uses the css...
14
lotus18
by: lotus18 | last post by:
Hello all I have these records on my Day Table for my complete database table please click here 1. M 2. T 3. W 4. TH 5. F 6. S
9
by: Meendar | last post by:
Hi, Below is my code snippet having only one form, <form> <input type ="radio" name="action" value="xyz" checked>xyz <input type ="radio" name="action" value="zyx">zyx <input type ="radio"...
5
by: voidinutah | last post by:
Hello, I'm new to .NET and was trying to find a solution for having a button control do a post back then execute a javascript function. When the button is clicked a post back occurs to save...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.