Question

EDIT: ANSWER: All I did was add an asp:hiddenfield. When I caculate the paydate I send the value to both fields. That way I never need to remove the disabled property from the visible datepicker, and I can use the hiddenfield value in vb.

I have a jquery datepicker ui input that is auto calculated from a different datepicker. I need to get the value of the datepicker in VB so I disable it html side, then enable it on form submit in jquery so that the value will pass to VB.

The problem is when I submit form and there are validation errors that cause a postback, the code still runs through the submit function and enables the input. Now the user can pick any date they want, when it needs to stay as the auto calculated date.

I changed it from disabled to read-only, but while read-only datepickers can't be typed in they can still be clicked and the picker comes up. I've tried to move the jquery code that enables the input around, but haven't been able to find a better place for it that only runs when the form is actually submitted. Now I'm trying to see if there is a way to keep the datepicker from opening when read-only is true.

Any ideas?

        $('#errorForm').submit(function () {
          $("#txtPayDate").prop("disabled", false);
          return validateExtraErrors();
        }); //jquery to enable input, validate, and submit form

<input type="text" id="txtPayDate" name="txtPayDate" value="<%=Request.Form("txtPayDate")%>" disabled="disabled"/> //input field
Was it helpful?

Solution

All I did was add an asp:hiddenfield. When I caculate the paydate I send the value to both fields. That way I never need to remove the disabled property from the visible datepicker, and I can use the hiddenfield value in vb.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top