简体   繁体   中英

Jquery datepicker - How do we hide the text inside a datepicker textbox?

I have two textbox side by side. The first textbox is a regular textbox.

The second textbox is a jquery datepicker. When user selects the date in the datepicker, I add the selected value to the first textbox and I would like to hide the value of the datepickers selected date.

I below is my jquery datepicker js but is not working as expected.

var $dataDescriptionTextBox = $("#descriptionTextbox"); 
$(".datePickerImage").datepicker({
        onSelect: function(dateText, thisObject) {
            thisObject.input[0].value = "";
            var desc = $dataDescriptionTextBox.val();
            var newDesc = desc + dateText;
            $dataDescriptionTextBox.val(newDesc);
            return false;
        }
    });

Thanks in advance for your help :)

Try this: http://jsfiddle.net/lotusgodkk/D4AGz/342/

JS:

$("#datepicker").datepicker({
    altField: "#alt"
});
$('#datepicker').on('change', function () {
    $(this).val("");
});

HTML:

<p>Date:
    <input id="datepicker" type="text" />
    <input id="alt" type="text" />
</p>

Two ways you can do this:

  1. Make the textcolor the same as the background color of the text box.
  2. Using onKeyPress event, after every keystroke take the value from your textbox, and append it into a hidden textbox you've got elsewhere on the page (or a javascript variable.

你尝试过这个吗?

$(".datePickerImage").text('');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM