Solved

Disable Validation for HTML submit button

Posted on 2013-10-30
9
253 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now