473,836 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript conflict

229 New Member
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 2420
fran7
229 New Member
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
3632
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 type="text/javascript">) to run? I'm asking because the following chunk of code (drop down menu that goes to different parts of the page) works without declaring anywhere that it's javascript:
1
2020
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: http://www.google.co.uk/search?q=cache:OPDjMJfL50sJ:www.adobe.com/svg/indepth/pdfs/ReadMewin.pdf+adobe+svg+javascript+problem&hl=en&ie=UTF-8#5 4. Due to design limitations of Netscape, avoid using HTML with the following form: <a href="#" onclick="myScriptWhichModifiesSVG()">The problem is that JavaScript responds to the onclick...
2
1340
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 snippet is as follows: <form action="names.html" enctype="multipart/form-data"
2
1727
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" style="position:absolute;"></div> <script src="staticlogo.js"> </script>
0
1537
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 used. The second piece of javascript pasted into the app serves as a data validation message box that fires after some server-side code executes (if a certain error condition exists). This action is tied to a submit button that upon NO error...
13
5348
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 using the setInterval function, like this: setInterval(function () {imageFade()},10); This works fine in Firefox, but in IE 7, the flash animations slow down a lot, and the javascript fading/rotation slows down some.
14
1968
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 p {color: #0000FF;} When i try to change that text- it will not change- the text on the page that is not assigned color in the external style sheet - changes just fine. Is there a conflict or does the css load after the javascript and undo the...
14
6911
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
1747
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" name="action" value="yxz">yxz </form>
5
4497
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 the user data, after that a javascript function is called to load a new video. If it wasn't for the video, then I would have used panel controls to hide/ show the content. We are using swfobject to load a series of videos on the same page, and...
0
9818
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9668
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10843
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7790
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6978
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5648
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4448
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4015
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.