如何显示文本框的警报消息为空 [英] How to show alert message for textbox empty
本文介绍了如何显示文本框的警报消息为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在文本跳过时显示警报按摩
我尝试过:
function userValid(){
var 描述;
描述= document .getElementById( TxtDescription 。跨度>)值;
if (Description == ){
alert( 请在说明中提及) ;
return false ;
}
返回 true ;
}
解决方案
试试这个,对于asp
< html xmlns = http:// www。 w3.org/1999/xhtml\">
< head >
< < span class =code-leadattribute> title > < / title >
< script type = text / javascript >
function userValid(){
var 描述= document .getElementById( <%= TxtDescription.ClientID%>);
if (Description.value == ){
alert( 请提及说明);
Description.focus();
return false ;
}
返回 true ;
}
< / 脚本 >
< / head >
< 正文 >
< form id = frm runat = 服务器 >
< asp:TextBox runat = server ID = < span class =code-keyword> TxtDescription / >
< asp:按钮 文本 = 保存 OnClientClick = return userValid(); runat = server / >
< / form >
< / body >
< / html >
i want to show alert massage for when the text skip
What I have tried:
function userValid() {
var Description;
Description = document.getElementById("TxtDescription").value;
if (Description == "") {
alert("Please Mention at Description");
return false;
}
return true;
}
解决方案
try this, for asp
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function userValid() { var Description = document.getElementById("<%= TxtDescription.ClientID %>"); if (Description.value == "") { alert("Please Mention at Description"); Description.focus(); return false; } return true; } </script> </head> <body> <form id="frm" runat="server"> <asp:TextBox runat="server" ID="TxtDescription" /> <asp:Button Text="Save" OnClientClick="return userValid();" runat="server" /> </form> </body> </html>
这篇关于如何显示文本框的警报消息为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文