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

Which button was clicked to cause validation?

Hello, it a .net app, in my client javascript code I would like to find
out what event caused the page to validate. No, setting a hidden this
or that will not do. I just want to know what event caused the
validation.
Thanks.
Jeff

Nov 23 '05 #1
7 2191
uj*****@gmail.com wrote:
Hello, it a .net app, in my client javascript code I would like to find
out what event caused the page to validate. No, setting a hidden this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ or that will not do. I just want to know what event caused the ^^^^^^^^^^^^^^^^^^^^ validation.


I beg your pardon?
PointedEars
Nov 23 '05 #2
uj*****@gmail.com said the following on 11/17/2005 3:09 PM:
Hello, it a .net app, in my client javascript code I would like to find
out what event caused the page to validate. No, setting a hidden this
or that will not do. I just want to know what event caused the
validation.


My stereo doesn't work. Can you tell me what is wrong? No, you can't do
this or that, just tell me why it doesn't work.

My point? You have not given enough details to be able to answer you.

What do you mean by "caused the page to validate"?

It sounds like you have a form with a validation routine where the form
has multiple ways to submit and you want to know which one caused the
submission.

Post more details.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 23 '05 #3
VK

uj*****@gmail.com wrote:
Hello, it a .net app, in my client javascript code I would like to find
out what event caused the page to validate. No, setting a hidden this
or that will not do. I just want to know what event caused the
validation.
Thanks.
Jeff


function validator(e) {
switch(e.type) {
case 'click' : ...; break;
case 'submit' : ....; break;
default: ...
}
}

Nov 23 '05 #4
I simply want to know what button caused the validation of the page to
fire. I.E. I have two buttons, in my validation I want to know which
one was clicked and fired the submit / validation to run.

Nov 28 '05 #5

uj*****@gmail.com wrote:
I simply want to know what button caused the validation of the page to
fire. I.E. I have two buttons, in my validation I want to know which
one was clicked and fired the submit / validation to run.


As others above have already stated, this is still not enough
information (to me anyways). Perhaps you should post some code
relevant to your problem. There can be several scenarios in which you
describe. For example, what kind of buttons are there? Are they in a
form? Is one of the buttons an html input element of type submit? Did
you attach an event handler to the buttons? In which case, then you
should know which one was clicked. And etc. etc.

Nov 28 '05 #6
asp button. has server side code. has a custom validator.
The server side code does not execute until the validation has ran.
in the client side javascript code for the custom validator, can I call
any type of a function to see what event caused the page to attempt
submit hence calling all validation.
Yes it's in a form.
The two buttons are btnSearchAddress and btnSearchParcel.
For instance, when <asp:customvalidator id="val_cust_ByAddress"
runat="server" Display="None"
ClientValidationFunction="val_cust_ByAddress_Clien tValidate"></asp:customvalidator>
runs it calls
function val_cust_ByAddress_ClientValidate(sender, args)
{
if (document.getElementById("txtNumber").value == "")
{
document.getElementById("val_cust_ByAddress").erro rmessage = "You
must enter a house number";
args.IsValid = false;
return;
}
}

and in there I want to test if search by address was clicked or by
parcel.

Here's some more of the code.

<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="536"
border="0">
<TR>
<TD class="text_basic_10" vAlign="top">
<TABLE id="Table4" cellSpacing="0" cellPadding="0" width="536"
border="0">
<TR>
<TD class="text_basic_8" style="WIDTH: 352px">
<asp:button id="btnClearAddress" runat="server" Width="48px"
CssClass="button" Text="Clear"
CausesValidation="False"></asp:button></TD>
<TD class="text_basic_8" style="WIDTH: 85px"></TD>
<TD class="text_basic_8" align="right">
<asp:button id="btnSearchAddress" runat="server" Width="48px"
CssClass="button" Text="Search"></asp:button></TD>
</TR>
</TABLE>
<TABLE id="Table5" cellSpacing="0" cellPadding="0" width="536"
border="0">
<TR>
<TD class="text_basic_8" style="WIDTH: 106px"><asp:button
id="btnClearParcel" runat="server" Width="48px" CssClass="button"
Text="Clear" CausesValidation="False"></asp:button></TD>
<TD class="text_basic_8" style="WIDTH: 115px"></TD>
<TD class="text_basic_8" style="WIDTH: 3px"></TD>
<TD class="text_basic_8" align="right"><asp:button
id="btnSearchParcel" runat="server" Width="48px" CssClass="button"
Text="Search"></asp:button></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<asp:customvalidator id="val_cust_ByAddress" runat="server"
Display="None"
ClientValidationFunction="val_cust_ByAddress_Clien tValidate"></asp:customvalidator><BR>
<asp:customvalidator id="val_cust_Street" runat="server"
Display="None"
ClientValidationFunction="val_cust_Street_ClientVa lidate"></asp:customvalidator>
<BR>
<asp:customvalidator id="val_cust_City" runat="server"
Display="None"
ClientValidationFunction="val_cust_City_ClientVali date"></asp:customvalidator>
<BR>
<asp:customvalidator id="val_cust_ZipCode" runat="server"
Display="None"
ClientValidationFunction="val_cust_ZipCode_ClientV alidate"></asp:customvalidator><BR>
<BR>
<asp:customvalidator id="val_cust_ParcelIDNumber" runat="server"
ErrorMessage="Parcel ID number required"
Display="None"></asp:customvalidator><BR>
<BR>
<asp:validationsummary id="val_summary" runat="server" Width="216px"
HeaderText="The following errors were found:"
ShowSummary="False" ShowMessageBox="True"></asp:validationsummary>
<script language="javascript">
function val_cust_ByAddress_ClientValidate(sender, args)
{
if (document.getElementById("txtNumber").value == "")
{
document.getElementById("val_cust_ByAddress").erro rmessage =
"You must enter a house number";
args.IsValid = false;
return;
}
}

function val_cust_Street_ClientValidate(sender, args)
{
if (document.getElementById("txtStreet").value == "")
{
document.getElementById("val_cust_Street").errorme ssage = "You
must enter a street name";
args.IsValid = false;
return;
}
}

function val_cust_City_ClientValidate(sender, args)
{
if (document.getElementById("ddlMunicipality").value == "-1" ||
document.getElementById("ddlMunicipality").value == "0")
{
document.getElementById("val_cust_City").errormess age = "You
must select a city";
args.IsValid = false;
return;
}
}

function val_cust_ZipCode_ClientValidate(sender, args)
{
if (document.getElementById("ddlZipCode").value == "-1" ||
document.getElementById("ddlZipCode").value == "0")
{
document.getElementById("val_cust_ZipCode").errorm essage = "You
must select a zip code";
args.IsValid = false;
return;
}
}

</script>
</form>

Nov 30 '05 #7
uj*****@gmail.com wrote:
asp button. has server side code. has a custom validator.
The server side code does not execute until the validation has ran.
So it is completely irrelevant here, yes?
in the client side javascript code for the custom validator, can I call
any type of a function to see what event caused the page to attempt
submit hence calling all validation.
Yes it's in a form.
The two buttons are btnSearchAddress and btnSearchParcel.
For instance, when <asp:customvalidator id="val_cust_ByAddress"
runat="server" Display="None"
ClientValidationFunction="val_cust_ByAddress_Clien tValidate"></asp:customvalidator> runs it calls
[...]
and in there I want to test if search by address was clicked or by
parcel.
Perhaps

function val_cust_ByAddress_ClientValidate(sender, args, action)
{
// use the value of action
}

<input type="button" name="foo"
onclick="val_cust_ByAddress_ClientValidate(..., ..., this.name)">

? If not, post the code the _client_ gets, i.e. the server generates.
Only relevant snippets of it, of course.
Here's some more of the code.
[...]


Who on Earth is supposed to read this junk?
You should at least post properly formatted code.
PointedEars
Nov 30 '05 #8

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

Similar topics

3
by: Jeff | last post by:
I need to intercept the Click event of a asp:Button on the client side so that i can disable it after they've clicked it... HOW can i do this?? I was thinking of making the button an HTML button...
2
by: Danny Wang | last post by:
HI, I have a dialog (window) with a drop-down list and an OK button. When user clicks the drop-down list, the app need to do some calculation and validation, so I put an Text_on_change event on...
5
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design...
2
by: Bernie Yaeger | last post by:
I validate - through a delegate - several textbox data when an 'add' button is clicked. However, when the 'close' button is clicked, I don't want to validate - I just want to window to close. I...
5
by: Jeff User | last post by:
Hello ..NET 1.1, VS 2003, C# & asp.net I have tried to follow msdn instructions and samples but I can not get an event to fire for this button on the datagrid. There has to be something obvious...
2
by: winnie_us99 | last post by:
Hi All, I am trying to do validation on my text field before going to the next page to create a user. It doesn't look like the next button will fire any validation. Am I missing something? Can...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
15
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
3
by: webster5u | last post by:
Hi, i have a question about JavaScript. When we click a submit button from the form with multi-submit button. Can JavaScript detect which submit button has been submit? I make a form with 3 submit...
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: 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
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
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...
0
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,...

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.