0

I have an input that as soon as the value is chnaged it submits the value and is saved in our database, therefore we can only allow date format values, and the best tool is using datepicker with a readonly input. the only issue is that once a date is set it cannot be removed (in our case is ok to have empty dates).

<input class="datepicker" readonly="readonly" type="text" />

<script>
$(".datepicker").datepicker({
        dateFormat: 'yy-mm-dd',
        yearRange: "-100:+20",
        changeYear: true 
    });
</script>

Is there a method part of datepicker that enables a way to erase the value without interacting with the input, or any other idea on how to accomplish this goal without creating new buttons or complicated UI elements?

Please keep in mind that this question is not about security implications, or if this is the best way to mantain the data integrity of our database, it is a JS / Jquery question. Thanks.

1
  • Your question is not very clear. Your first problem is that as soon as the input is changed, the value gets submitted. Yet, you want the ability to change the value before it's submitted. It seems you have to prevent auto-submitting, but since you have not shown us the code that does that, it's hard to help you with that problem. The 2nd issue is you want the ability to clear the selected value, but you don't want it to be via interacting with the input field, nor by any new button or UI element. How, then, would you like it to work? Not the underlying mechanics, but from a UI perspective?
    – kmoser
    Commented Jul 4 at 5:11

0

Browse other questions tagged or ask your own question.