JavaScript------如何解决表单登录信息输入为空显示提示

<form name="fname" method="post" action="../Home/Login" onsubmit="return My();">
        <input type="text" name="user" />
        <input type="submit" value="提交"/>
</form>

 

function My() {
    var s = document.forms["fname"]["user"].value;
    if (s == null || s == "") {
        alert("不能为空");
        return false;
    }  
}

 

posted @ 2017-01-13 16:40  玉天恒  阅读(363)  评论(0编辑  收藏  举报