Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 860543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:50:00+00:00 2026-05-15T08:50:00+00:00

I have a textbox with jquery ui datetime picker. When i open the page

  • 0

I have a textbox with jquery ui datetime picker. When i open the page jquery clears my textbox.(Textbox has a default value) Is there any way to prevent this action?

View:

<div class="editor-field">
                <%: Html.TextBoxFor(model => model.Start, String.Format("{0:g}", Model.Start)) %>
                <%: Html.ValidationMessageFor(model => model.Start) %>
</div>

.js

$(document).ready(function () {
$("#Start").datepicker({
        showOn: 'button',
        buttonImage: '../../Content/img/cal.jpg',
        buttonImageOnly: true,
    });
$( "#Start, #End").datepicker( "option", "showAnim", 'slideDown' );
});

Thank you,
Peti

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:50:00+00:00Added an answer on May 15, 2026 at 8:50 am

    Can you grab the value before the call and then set it again after?

    $(document).ready(function () {
        var default_date = $("#Start").val();
        $("#Start").datepicker({
                showOn: 'button',
                buttonImage: '../../Content/img/cal.jpg',
                buttonImageOnly: true,
            });
        $( "#Start, #End").datepicker( "option", "showAnim", 'slideDown' );
        $("#Start").val(default_date);
    });
    

    That said, I’m guessing that there’s some other problem. It’s been a while since I’ve used the datepicker plugin, but I can’t imagine it’s setup to blow out a valid date value from the input when you create it.

    Can you post your code somewhere like Pastebin?

    EDIT:

    Oh, you’re right about the format. The default date format it expects is mm/dd/yy. What you’ll want to do is set the date format option to reflect your particular format. You’ll also want to strip off the time component from the date value. The code would look something like this (may not be 100% coreect):

    $(document).ready(function () {
        var date_stripped_of_time = $("#Start").val().substring(0, 10);
        $("#Start").val(date_stripped_of_time);
        $("#Start").datepicker({
                showOn: 'button',
                buttonImage: '../../Content/img/cal.jpg',
                buttonImageOnly: true,
                dateFormat: 'yy.mm.dd',
            });
        $( "#Start, #End").datepicker( "option", "showAnim", 'slideDown' );
    });
    

    You can read more by looking at the options tab in the DatePicker documentation, and the formatDate documentation to see what you can use for the dateFormat string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standard textbox and I've got jQuery on the page. I want
does jquery have any plugin that prevents entering any input to a textbox that
I am using jquery on asp.net mvc. I have textbox on page and I
I have this code to prevent people entering '£' into a textbox jQuery(document).ready(function(){ jQuery('#cp_price').keypress(function(e){
I'm using MVC2 and have included the Jquery DateTime picker. For some reason it
I have a textbox which has JQuery UI DatePicker control registered to it. It
I've recently added the JQuery autocomplete plug in and have a textbox that autocompletes
I'm using redactorjs , It's a WYSIWYG editor on jQuery. I have a textbox
I have a ASP.NET textbox autocomplete with JQuery, is working perfectly, i type part
I have problem while using jquery maskedinput with asp.net textbox. I have a check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.