473,395 Members | 2,253 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,395 software developers and data experts.

Help in referencing object

Hi All,

I'm not a javascript programmer, but I'm trying to accomplish something
here that is not working.

I have 2 buttons on an HTML form, along with several text fields. If
Button #1 is clicked, I only want to validate some of the text fields,
if Button #2 is clicked, I want to check them all.

I'm having trouble referencing the button name that was clicked.
Snippets of my code is below, if someone can help me please.

Thanks

..
..
..
<script language="javascript">
function validate(thisform) {
with (thisform)
if (thisform.action.value == "Duplicate") {
if (emptyvalidation(subject,"Subject is empty")==false)
{subject.focus(); return false;}
}
if (thisform.action.value == "Save") {
if (emptyvalidation(subject,"Subject is empty")==false)
{subject.focus(); return false;}
if (datevalidation(PartyDate,"Please select a valid Date")==false)
{PartyDate.focus(); return false;};
if (valButton(party_domain) == null) {alert('No Party Location
selected'); return false;};
if (isOneCheckboxChecked(thisform) == false) {alert('No List
Selected'); return false;};
}}
..
..
..
<FORM NAME='NEW_MENU' ACTION='sched.pl' METHOD=POST onsubmit="return
validate(this)">
..
..
..
<input type='submit' name='action' VALUE='Duplicate'
onclick="validate(this);">
<input type='submit' name='action' VALUE='Save'
onclick="validate(this);">
..
..
..

Jan 24 '06 #1
2 1105
VK

am****@iwc.net wrote:
Hi All,

I'm not a javascript programmer, but I'm trying to accomplish something
here that is not working.

I have 2 buttons on an HTML form, along with several text fields. If
Button #1 is clicked, I only want to validate some of the text fields,
if Button #2 is clicked, I want to check them all.

I'm having trouble referencing the button name that was clicked.
Snippets of my code is below, if someone can help me please.


"submit" event for form contains form itself as target / srcElement, so
this approach won't fly. Thinking of the minimum code change: you can
use mouseup instead for buttons (maybe not what W3C would like to see,
but it works)

<script type="text/javascript">
var chosenAction = "";

function validate(f) {
if (chosenAction == "Duplicate") {
if (emptyvalidation(f.subject,"Subject is empty")==false)
{f.subject.focus(); return false;}
}
if (chosenAction == "Save") {
if (emptyvalidation(f.subject,"Subject is empty")==false)
{f.subject.focus(); return false;}
if (datevalidation(f.PartyDate,"Please select a valid Date")==false)
{f.PartyDate.focus(); return false;}
if (valButton(f.party_domain) == null)
{alert('No Party Location selected'); return false;}
if (isOneCheckboxChecked(f) == false)
{alert('No List Selected'); return false;}
}
}

<FORM NAME='NEW_MENU' ACTION='sched.pl' METHOD=POST
onsubmit="return validate(this)">

<input type='submit' name='action' VALUE='Duplicate'
onmouseup="chosenAction=this.value">
<input type='submit' name='action' VALUE='Save'
onmouseup="chosenAction=this.value">

Jan 25 '06 #2
I like this modular code approach. I'll try and implement it and let
you know.

Honestly tought, I do not understand what you mean when you say "Don't
validate in the onclick handler of the submit element".

I'm not a good object programmer.......so if you can explain, that'd be
helpful.

Jan 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon | last post by:
Am using the following code. <script language="JavaScript1.2"> function setquantity(productindex,productquantity) { //create the reference object irefname_none = eval("document." +...
2
by: Tarren | last post by:
Hi: The problem I am having is when I validate an xml file to a schema, it is erroring out every element. I think this has something to do with me defining/referencing the namespaces. I have...
7
by: Douglas Robson | last post by:
Ok, I've removed the MyItem class which is found in References.cs and replaced it with a reference to the namespace that has MyItem in it. I've also got rid of the tag at the top of the MyItem...
9
by: Brett Romero | last post by:
Say I have a library (A.dll) with a method that accepts a collection of a specific type. The type is defined in B.dll. In A.dll, I need to loop through this collection and reference fields of...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
4
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
5
by: sajin | last post by:
Hi All.. We are using VB .Net 2005 for implementing an API. API needs to generate events. For this client wants us to use Windows Callback (delegate implementation). The intention of using...
2
by: Andrus | last post by:
I need compile in-memory assembly which references to other in-memory assembly. Compiling second assembly fails with error Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0, Culture=neutral,...
32
by: =?Utf-8?B?U2l2?= | last post by:
I have a form that I programmatically generate some check boxes and labels on. Later on when I want to draw the form with different data I want to clear the previously created items and then put...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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
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...

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.