Solved

Disable Validation for HTML submit button

Posted on 2013-10-30
9
256 Views
Last Modified: 2013-11-24
Hello,

I have web page designed in Visual Studio 2003.

On that page I have 20 text fields and a save button. (all ASP controls)

On some of the text fields there is a basic validation set. (to not allow empty fields to be saved)

For Save button there is a property called causesValidation that is set = True by default, so my validation works fine for this button.

However, in addition to all this, on the same page ,I have Upload file HMTL fields that include Browse and Upload buttons (in basic HTML, I believe)

I browse to the file I want to upload fine. When I click on Upload button, that click causes validation on my text fields (mentioned above)

How I can set the HTML submit button to NOT cause validation? and to simply proceed with the upload process only.

Thanks
0
Comment
Question by:Terrace
  • 4
  • 4
9 Comments
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39611845
By "all the controls", do you include the buttons? Buttons and validators need to have separate validation groups assigned in order to be mutually exclusive.

Please validate that both submit buttons have a validation group assigned, and that all validators have a validation group assigned corresponding to the button that should cause that validator to validate.

As an alternative, you can set CausesValidation to false on the filter button if there needs be no validation performed at all.
0
 

Author Comment

by:Terrace
ID: 39612835
Hello,

thanks for your reply.
Currently none of the buttons have validation groups assigned.

Before the Upload button was on the page, I had only one button, Save button.

That Save button has causesvalidation = True, so that button triggers validation on ALL fields that have validation set.

I added Upload feature to this same page, so now I have Upload button too (this button is HTML). Now when this button is clicked it also triggers validation on ALL fields.

Since this Upload button is HTML, it does not have property causesvalidation, so I can not set any value to it.

Ideally I would like to force Upload button to NOT do any validation.

is there a way to set causesvalidation = FALSE to html upload/submit button ?

Thanks
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39617377
One option is to set validation group on all other controls with the save button. That way, upload button should not trigger validation as it would not be part of that group.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

Author Comment

by:Terrace
ID: 39620145
That sounds like a plan.

Can you please give me an example of how that is done?

Ex.

If I have Textbox1 and Textbox2 with validation set on them.
How do I set that validation is triggered specificaly by buton Save only?

Thanks
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39620150
You just need to set the ValidationGroup property to same value on both textboxes and button.
0
 

Author Comment

by:Terrace
ID: 39621124
Thanks,

I am sure this is available in newere .NET frameworks, like 4.0 for example.

How to set the ValidatioGroups in .NET framework 1.1 ( Visual Studio 2003) ?

I don't see ValidationGroup property for textbox.

Maybe have to use JavaScript of some sort?

Thanks
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39621176
Try just adding

ValidationGroup="groupname"

In aspx code manually.
0
 

Author Comment

by:Terrace
ID: 39623892
Thanks. I tried adding this in the html part of the page in textbox contol settings, but it did not work.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39624246
Can you show a simplified aspx source code?

Also, why html input and not ASP.NET button?
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question