3

I want to reset a form but I'm using a few "Required Field Validator" every time I click the reset button the error message shows requiring fields... What I tried:

ReuiqredFieldValidator.Enabled = false; 
TextBox.Text="";


Response.Redirect("Samepage.aspx");
Response.Redirect("Request.RawUrl");

<input type=reset>
Majid
  • 13,853
  • 15
  • 77
  • 113
Syed Ali Taqi
  • 4,898
  • 3
  • 34
  • 44

3 Answers3

2

Try this:

<asp:Button 
runat="server" 
ID="reBt" 
Text="Reset" 
OnClientClick="this.form.reset();return false;" 
CausesValidation="false"
/>

from here

Majid
  • 13,853
  • 15
  • 77
  • 113
1

You can apply ValidationGroup property to group of controls and the relevant asp button and do not provide ValidationGroup to reset button.

Or same can be achieved vice-versa

This is applicable as you using asp.net controls

Refer this link

Chirag Vidani
  • 2,519
  • 18
  • 26
0

you can try it

<input type="reset" causesvalidation="False">

It should work.
It works for input submit so I think it should work on input reset also.

Details Input =submit

Edit 1

Or if you are using jQuery you can use like this

$(':input','#myform')
 .not(':button, :submit, :reset, :hidden')
 .val('')
 .removeAttr('checked')
 .removeAttr('selected');

References

  1. Clear form fields with jQuery
  2. How to reset a form using jQuery with .reset() method

jQuery reference

:reset Selector

Community
  • 1
  • 1
शेखर
  • 17,412
  • 13
  • 61
  • 117
  • @majidgeek visit this it is for .net framework 4.5 [link](http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputbutton.causesvalidation%28v=vs.110%29.aspx) – शेखर May 15 '14 at 05:25