Which button was clicked to cause validation?

U

ujjc001

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
 
T

Thomas 'PointedEars' Lahn

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
 
R

Randy Webb

(e-mail address removed) 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.
 
V

VK

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: ...
}
}
 
U

ujjc001

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.
 
W

web.dev

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.
 
U

ujjc001

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_ClientValidate"></asp:customvalidator>
runs it calls
function val_cust_ByAddress_ClientValidate(sender, args)
{
if (document.getElementById("txtNumber").value == "")
{
document.getElementById("val_cust_ByAddress").errormessage = "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_ClientValidate"></asp:customvalidator><BR>
<asp:customvalidator id="val_cust_Street" runat="server"
Display="None"
ClientValidationFunction="val_cust_Street_ClientValidate"></asp:customvalidator>
<BR>
<asp:customvalidator id="val_cust_City" runat="server"
Display="None"
ClientValidationFunction="val_cust_City_ClientValidate"></asp:customvalidator>
<BR>
<asp:customvalidator id="val_cust_ZipCode" runat="server"
Display="None"
ClientValidationFunction="val_cust_ZipCode_ClientValidate"></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").errormessage =
"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").errormessage = "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").errormessage = "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").errormessage = "You
must select a zip code";
args.IsValid = false;
return;
}
}

</script>
</form>
 
L

Lee

(e-mail address removed) said:
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_ClientValidate"></asp:customvalidator>
runs it calls
function val_cust_ByAddress_ClientValidate(sender, args)
{
if (document.getElementById("txtNumber").value == "")
{
document.getElementById("val_cust_ByAddress").errormessage = "You
must enter a house number";
args.IsValid = false;
return;
}
}

When posting code, convert all tabs to 2 spaces to help avoid wrap.
You should also trim the code to the smallest tested block that
shows what you're talking about.
 
T

Thomas 'PointedEars' Lahn

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_ClientValidate"> said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top