473,804 Members | 3,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Execute client side script when validation fails - how?

I have a form with 16 fields, 10 of which use the
RequiredFieldVa lidator controls. I want to display a custom message
when the validation fails. However, all the validators have
ClientScript enabled so there is no postback.

What can I hook into on the client side to execute other client side
script (eg. show a hidden label or popup) if validation fails?
Jan 17 '07 #1
2 2073
Can somebody help me out with this please?
Jan 18 '07 #2
Sure,

<asp:TextBox runat="server" ID="TextBox1" CausesValidatio n="false"/>
<asp:RequiredFi eldValidator runat="server" ID="RequiredFie ldValidator1"
ControlToValida te="TextBox1"
ErrorMessage="" Display="Dynami c" EnableClientScr ipt="true"/>

<asp:TextBox runat="server" ID="TextBox2" CausesValidatio n="false"/>
<asp:RequiredFi eldValidator runat="server" ID="RequiredFie ldValidator2"
ControlToValida te="TextBox2"
ErrorMessage="" Display="Dynami c" EnableClientScr ipt="true"/>

<asp:TextBox runat="server" ID="TextBox3" CausesValidatio n="false"/>
<asp:RequiredFi eldValidator runat="server" ID="RequiredFie ldValidator3"
ControlToValida te="TextBox3"
ErrorMessage="" Display="Dynami c" EnableClientScr ipt="true"/>

<asp:Button runat="server" ID="Button3" Text="Click!" OnClientClick=" return
ValidateUserDat a();"/>

<script type="text/javascript">
function ValidateUserDat a()
{
for (i = 0; i < Page_Validators .length; i++)
{
ValidatorValida te(Page_Validat ors[i]);
}

ValidatorUpdate IsValid();

if (Page_IsValid == true)
{
return true;
}
else
{
alert('my custom code!');
return false;
}
}
</script>

--
Milosz
"turboJeepe r" wrote:
Can somebody help me out with this please?
Feb 1 '07 #3

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

Similar topics

3
1272
by: Gareth | last post by:
Hi, I've just published a test web site on the internet with a simple form and some client side validation controls. On my development PC if I click submit without entering any data the validation controls work and prompt me as expected. On the live web server I do exactly the same thing but no validation is performed and the form is submitted. How can this be? Have I missed something in the setup script? I added both the primary...
6
2920
by: Brian Miller | last post by:
I've been constructing an ASP.Net application using the 1.1 framework, and have been using Web Matrix for development purposes. Now that my application is near completion, I wanted to see if I can set up my pages for access directly via localhost (not using the WebMatrix server). My login page loads, and any validation controls on the page work fine, so I know it's recognizing the ASP.Net code there, however, when I try to log on, the...
1
5243
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that appear to be the result of double-clicking the submit button on the form. The form has three ASP:Button tags, each of which gets translated into INPUT TYPE="SUBMIT" HTML elements. One submits the form's data. One logs the user out. And the other...
3
12754
by: deride | last post by:
For client side validation, the following code is generated by the framework <form name="Form1" method="post" onsubmit=" if (!ValidatorOnSubmit()) return false; MyFunction..."> My Problem is that, I need to call another javascript function regardless of whether or not ValidatorOnSubmit() is true or false (i.e client side validation fails or passes). My WebUIValidation.js has function ValidatorCommonOnSubmit() { var result =...
1
2525
by: vidya | last post by:
Hi, I have a button which is a web control. I have some validation in javascript for the button in .aspx file and some in the button onclick event in code behind(C#). I need to get through both the java script validation as well as the click in code behind? How can this be done ? Can I call the code behind from the javascript function? If not can i have a separate procedure in C# file and call it from the javascript function? If so...
1
3954
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had the same issue. However, none of the suggested fixes solved my particular problem. I tracked down the cause of the problem, which is related to aspx page parser's handling of controls inside html comments. The problem may be quite common and well...
6
3858
by: Mike Chen | last post by:
We know in server code, we can check the page validated by using Page.IsValid where we put some validator controls on aspx page. I want to set some value after validating user input values on client side and before page posts to server. How can i get the functionality of client side Page.IsValid? thanks.
1
1234
by: Velvet | last post by:
Does anyone know a way to force the client script to preform a client-side validation for controls in validation groups? What is currently happening is I have two validation groups (Billing, CreditCard). The validation doesn't happen until the submit button is pressed and the server validation happens. I added an OnClickClient event to the submit button that pops up a comfirm box, but it pops before any validation happens. What I...
2
1487
by: Bogdan | last post by:
Hi, I'd like to display (i.e. make visible) a label after a submit button is clicked but only if the client-side validation is successful. If I did not care about the validation then I'd simply modify style.display of the label in my onclick (OnClientClick) script. The problem is that my script will execute before the validation script. Is there a way to execute my custom script after the validation takes place? Thanks,
0
9588
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
10589
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
10085
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...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7625
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
6857
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
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
3828
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.