how can i do it with JQuery? I use the change event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input.
How to do it?
Thanks!
You can do this without Javascript. Using HTML5 is easier:
<input type="text" placeholder="default text" />
$('idOfInputTextBox').writeAttribute('placeholder', theChangedDateString);Here's how I usually do it.
<form id="myform">
<input name="box" type="text" value="Type here">
</form>
_
$("input[name='box']", "#myform").bind("blur focus", function() {
if ($(this).val() == "" ) {
$(this).val("Type here");
}else if ($(this).val() == "Type here" ) {
$(this).val("");
}
});
And here's a fiddle to show how it works: http://jsfiddle.net/cR6P8/1/
If necessary it could probably be bound to the load event as well.
Actually your question is not very clear but ,,
var yourVaribale;
$('yourTextSelector').val(yourVariable)
u can set a value of an input text like above
you can do something like
$(document).ready(function(){
if ($("input[id$='your textbox id']").val().length == 0 || $("input[id$='your textbox id']").val().trim() == " ") {
$("input[id$='your textbox id']").val("something");
});