HTML
<form id="cangpin_sel" style="position:relative;" action="select_pingji.php" method="get" name="formsearch" autocomplete="off" >
<input id="lsm" type="text" name="collection_number" value="" />
<label for="lsm" id="message">021401705350</label>
<input id="select_sub" type="submit" value="点击查询" onclick="formSubmit()" />
</form>
CSS
#message{font-size: 16px;color:#ccc;position: absolute;top:13px;left:72px;cursor: text;}
js
$(function(){
function $(id){ return document.getElementById(id);}
$("lsm").focus();//自动获取光标方法
$("lsm").oninput = $("lsm").onpropertychange = function () {
//oninput 大部分浏览器支持 检测用户表单输入内容
//onpropertychange ie678 检测用户表单输入内容
if ( this.value == ""){
// 首先判断文本框里的值是否为空。注意用双等号!
$("message").style.display = "block";
$("direct").style.display = "block";
} else {
$("message").style.display = "none";
$("direct").style.display = "none";
}
}
});
function formSubmit()
{
var val = $("#lsm").val();
var moren = $("#message").html().trim();
if(val == '')
{
$("#lsm").attr("value",moren);
$("message").style.display = "none";
//alert(val);
$("cangpin_sel").submit();
}
else
{
$("cangpin_sel").submit();
}
}