0

I am trying to set a date of today to indicate user to input date in the textbox. To indicate this I have wrote this small javascript/jquery, and this is working in other test project but it is not working in my actual project. I am wondering what I have done wrong. Below is my script code:

$(document).ready(function () {
            var dObj = new Date();
            var foo = dObj.toLocaleDateString();
            $("#dte").val(foo);

        });

I am also confused about the position to attach a jquery link, whether it should be attach in .Master page or on content page before the corresponding close tag. Because when I attach this on master page it is giving me error like not able to find form1 and on latter one place it is not able to display the output in text box.

I have heard about placeholder and modernizer but it doesn't fulfil requirement of displaying date on page load. However, when ever I am giving value(date of today) to textbox inside Page_load method, i am not able to fetch the date that the user has selected. That is why I moved to this javascript solution. I am using AJAX date calendar extender to display calendar. Is it due to any ajax effect or something else.

please guide me regarding this.

Thanks!!

2
  • try placing your jquery link in this page and see if it works. Links followed by the above code. Placeholder is not the exact solution as it does not work in the old browsers. Commented Sep 20, 2014 at 7:12
  • @Nadeem Thanks for your response, I have already tried this.. please read the description again. thanks!! Commented Sep 20, 2014 at 7:14

1 Answer 1

1

Are you using server control TextBox? if so did you tried ClientID for JQuery selector

$("#<%=dte.ClientID%>").val(foo);
Sign up to request clarification or add additional context in comments.

1 Comment

Your advice helped me a lot but then I was not able to remove that JavaScript date; cuz right after the submit action or edit action the java script date come in the box, that I was not able to remove after postback. that made me to think about imagebutton (to display Ajax calendar control. If you have 2 minutes could you please suggest me how can I make use attributes of classic asp concept. Thanks!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.