Solved

Disable Validation for HTML submit button

Posted on 2013-10-30
9
258 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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