Тект в форме по умолчанию. Замена пустого значения в форме. JQUERY (jquery)
Тект в форме по умолчанию. Замена пустого значения в форме.
1. Подключаем jquery.Code: JavaScript
<script src="jquery.js" type="text/javascript"></script>
2. Оформляем текст, которые будет отображаться при пустом значении поля в форме. <
Code: CSS
<style media="screen" type="text/css">
.defaultTextActive { color: #a1a1a1; font-style: italic; }
</style>
Code: JavaScript
<script language="javascript">
<!--
$(document).ready(function()
{
$( ".defaultText" ).focus(function(srcc)
{
if ($(this).val() == $(this)[0].title)
{
$(this).removeClass( "defaultTextActive" ) ;
$(this).val( "" ) ;
}
}) ;
$( ".defaultText" ).blur(function()
{
if ($(this).val() == "" )
{
$(this).addClass( "defaultTextActive" ) ;
$(this).val($(this)[0].title) ;
}
}) ;
$( ".defaultText" ).blur() ;
}) ;
//-->
</script>
Code:
<input class="defaultText" title="Ваше Имя" type="text" />
Code: JavaScript
$(".submit").click(function() {
if($(".defaultText").attr("title") == $(".defaultText").val()){
$(".defaultText").val("");
}
});