Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > making validation happen only when a button is clicked

Reply
Thread Tools

making validation happen only when a button is clicked

 
 
Humberto Alvarez
Guest
Posts: n/a
 
      08-29-2005
Hi All



I'm using asp requiredfieldvalidator and regularexpressionvalidator 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
causesvalidation=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


 
Reply With Quote
 
 
 
 
Peter Blum
Guest
Posts: n/a
 
      08-29-2005
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 EventsThatValidate 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 EnableClientScript 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="multipart/form-data" > which is normally done with <input
type=file> tags.

That means the RegularExpressionValidator 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: http://www.velocityreviews.com/forums/(E-Mail Removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Humberto Alvarez" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All
>
>
>
> I'm using asp requiredfieldvalidator and regularexpressionvalidator 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
> causesvalidation=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
>
>



 
Reply With Quote
 
 
 
 
Peter Blum
Guest
Posts: n/a
 
      08-29-2005
FYI: I answered this on your cross posting in the
public.dotnet.framework.aspnet newsgroup.

--- Peter Blum
www.PeterBlum.com
Email: (E-Mail Removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Humberto Alvarez" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All
>
>
>
> I'm using asp requiredfieldvalidator and regularexpressionvalidator 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
> causesvalidation=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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suppress validation in a page when a button on a master page is clicked rmp_colo@hotmail.com ASP .Net 1 08-22-2007 07:18 PM
Validation Problems, Require text box if a radio button is clicked djjohnst ASP .Net 0 06-06-2007 03:28 PM
Which button was clicked to cause validation? ujjc001@gmail.com Javascript 8 11-30-2005 04:23 PM
making validation happen only when a button is clicked Humberto Alvarez ASP .Net Web Controls 0 08-29-2005 03:44 PM
Form Validation - check textbox filled in if radio button clicked Claire Osborne Javascript 3 02-10-2004 06:05 PM



Advertisments