<a>标签如何用js判断后不跳转
本帖最后由 s781112 于 2013-12-20 11:05:31 编辑 我想当文本框没输入任何东西时,点击链接按钮不进行跳转。js我是这样写的。
<script type="text/javascript">
function isNull(){
var email=document.getElementById("email").value;
alert(email);
var Msg=document.getElementById("emailMsg");
if(email=="")
{
Msg.innerHTML("请输入邮箱");
return false;
}
return true;
}
function checkall(){
if(isNull){
return true;
}
else
{
return false;
}
}
</script>
<input name="email" id="email" type="text"/>
<a href="index.jsp" onclick="checkall()">hh</a>
<span id="emailMsg"></span>
function checkall(){
if(isNull){
window.location.href = 'index.jsp';
}
else
{
return false;
}
}
<a href="javascript:checkall();">hh</a>
<script type="text/javascript">
function isNull(){
var email=document.getElementById("email").value;
alert(email);
var Msg=document.getElementById("emailMsg");
if(email=="")
{
Msg.innerHTML("请输入邮箱");
return false;
}
window.location.href = 'index.jsp';
}
</script>
<input name="email" id="email" type="text"/>
<a href="index.jsp" onclick="isNull()">hh</a>
<span id="emailMsg"></span>