473,698 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

making validation happen only when a button is clicked

Hi All

I'm using asp requiredfieldva lidator and regularexpressi onvalidator to
validate a text field and a file input field respectively. The validation
messages (the text property of the validation controls) display when the
controls to validate loose focus and not only when the submit button (with
causesvalidatio n=true ) is pushed.

I want these validation messages to display just when the button is pushed
and not when the controls to validate loose focus. How could I do this?

Thanks,

Humberto
Nov 19 '05 #1
2 1940
Hi Humberto,

If you are attempting to get client-side validation when the user submits,
then you cannot do this with the ASP.NET validators. Its not supported. My
replacement to the ASP.NET validators, Professional Validation And More
(http://www.peterblum.com/vam/home.aspx), does support this. Each of its 25
validators has a property called EventsThatValid ate that can be set to
"onchange", "onsubmit", or "both" (the default).

If you elect to abandon client side validation, its easy. Just set each
validator's EnableClientScr ipt property to false. Now the button's OnClick
method will validate for you, only after a post back. (Don't forget to
ALWAYS test Page.IsValid is true inside the Click event method before
saving.)

Here's the problem. The file input field will not pass along the file path
in its textbox field to the server side when using <form
enctype="multip art/form-data" > which is normally done with <input
type=file> tags.

That means the RegularExpressi onValidator will not have anything to evaluate
on post back. You cannot test that the user added a specific file extension,
for example. The usual rule is to evaluate the contents of the file passed
to you to be sure its the desired format (and virus free!). You can use a
CustomValidator to run your own code that does this and report errors back
to the user.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Humberto Alvarez" <vi********@hot mail.com> wrote in message
news:O2******** ******@TK2MSFTN GP09.phx.gbl...
Hi All

I'm using asp requiredfieldva lidator and regularexpressi onvalidator to
validate a text field and a file input field respectively. The validation
messages (the text property of the validation controls) display when the
controls to validate loose focus and not only when the submit button (with
causesvalidatio n=true ) is pushed.

I want these validation messages to display just when the button is pushed
and not when the controls to validate loose focus. How could I do this?

Thanks,

Humberto

Nov 19 '05 #2
FYI: I answered this on your cross posting in the
public.dotnet.f ramework.aspnet newsgroup.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Humberto Alvarez" <vi********@hot mail.com> wrote in message
news:O2******** ******@TK2MSFTN GP09.phx.gbl...
Hi All

I'm using asp requiredfieldva lidator and regularexpressi onvalidator to
validate a text field and a file input field respectively. The validation
messages (the text property of the validation controls) display when the
controls to validate loose focus and not only when the submit button (with
causesvalidatio n=true ) is pushed.

I want these validation messages to display just when the button is pushed
and not when the controls to validate loose focus. How could I do this?

Thanks,

Humberto

Nov 19 '05 #3

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

Similar topics

7
2775
by: Marina | last post by:
Imagine a form with some fields and an OK buttons that saves the information. Each field has validation logic in the Validating event. If the input is not valid, the control's value is replaced with the last value it had before the user changed it. Pretty typical Now, the user types some invalid value and clicks OK. The user gets a message saying the value is not valid, and the bad value is replaced with the last good one. So far, so...
7
2870
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How can have the validator just disable certain control's postback and other part of page continue their functionality. Thanks,
3
1002
by: Russ | last post by:
How can I cause validation to not take place when a certain button click event fires? I have a page with 2 buttons. If one of them is clicked I want the field validated. If the other is clicked I do not want it validated. I have been unable to find a way to make this happen. Thanks, Russ
5
3241
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit my edits since the footer validation kicks in.If I take the validation off then the both work fine...
1
6559
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I have a separate submit button which should validate the other fields. This page on MSDN does what I want - almost! ...
3
1441
by: aljodo | last post by:
ASP.Net v1.1 & vb.net Hi all, I have a simple survey form with first name/last name text boxes at the top. I have validators on these text boxes to ensure that something is entered in them. The form has a Submit button (asp:button) at the bottom and if the validation has failed I want the form to return to the top, so that the
9
3181
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected... So the behavour is similar to a tab control. The user is expected to fill out required data on each of the panels before pressing a submit button which is visible from all panels. Problem I have is validating the data entered by the user. I...
2
2109
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 know how to override the validation when the window's 'x' button is clicked with the following: Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = &H10 Then needvalidating = False
5
3811
by: Micky | last post by:
VB v7.1.3088 NET v1.1.4322 SP1 My mate has a strange problem regarding the ESC key and validation. When he hits the Cancel button on his form, the form does not validate. This is correct behaviour of course. However, he also wants this same behaviour when hitting ESC on the keyboard. It was my understanding that when you assign a button to a form's CancelButton property you automatically gained this functionality. However,
0
8611
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
9170
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
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7741
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
6531
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
4372
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...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.