I have a RadDatePicker control on a form and I use the following script to reset the form fields after I save the data through an AJax call:
$.fn.clearForm = function () {
return this.each(function () {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form' || tag == 'div'||tag=='tr'||tag=='td')
return $(':input', this).clearForm();
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = '';
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = '';
});
};
If after filling out the form and saving it I clear the fields, using the above jQuery script, the required field validation I have set up for the RadDatepicker fires even if you select a date. If I try the isEmpty() client call on the control it returns false so it does have a value. If you type a date manually in the input field in stead of selecting it through the calendar the required field validation does not fire.
The problem is obviously the script I use to clear the form fields as it works fine if I do not reset the fields. Can you tell me how I could/should go about this?
$.fn.clearForm = function () {
return this.each(function () {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form' || tag == 'div'||tag=='tr'||tag=='td')
return $(':input', this).clearForm();
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = '';
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = '';
});
};
If after filling out the form and saving it I clear the fields, using the above jQuery script, the required field validation I have set up for the RadDatepicker fires even if you select a date. If I try the isEmpty() client call on the control it returns false so it does have a value. If you type a date manually in the input field in stead of selecting it through the calendar the required field validation does not fire.
The problem is obviously the script I use to clear the form fields as it works fine if I do not reset the fields. Can you tell me how I could/should go about this?