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