0

i am making a form that has a date field using textfield, i want my date field to have a label format inside the textfield, here's the picture: enter image description here after clicking on the textfield the format will be erased and the hyphen will remain like this picture: enter image description here i already made the code for the label format, here's my code:

<input type="text" name="date" value="DD_MM_YYYY" id="date" style="width:180px" onclick="if(this.value=='DD_MM_YYYY'){this.value=''}"  />
</p>

My problem now is the hypen that will remain after clicking the textfield.

Anyone knows how to do that?

Thanks in advance.

4

2 に答える 2

1

マスクされた入力プラグインをお勧めします。
http://digitalbush.com/projects/masked-input-plugin/

次のコードを使用して、独自のタイプのマスクを定義できます。

jQuery(function($){
   $("#myinput").mask("99-99-9999",{placeholder:" "});
});

次に、入力のプレースホルダーを定義できます。

<input id='myinput' placeholder='dd-mm-yyyy'>
于 2013-01-10T02:44:25.140 に答える
0

プレースホルダー属性を使用できます。

<input placeholder="  -  -    " value="DD-MM-YYYY" />

要素がフォーカスされているときは、値を何にも設定し続けることができます。ぼかしの場合、値をに戻しDD-MM-YYYYます。

この属性は、すべてのブラウザでサポートされているわけではないことに注意してください。

于 2013-01-10T02:44:34.350 に答える