Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to show alert massage for when the text skip

What I have tried:

JavaScript
function userValid() {
    var Description;
    Description = document.getElementById("TxtDescription").value;

    if (Description == "") {
        alert("Please Mention at Description");
        return false;
    }
    return true;
}
Posted
Updated 31-May-16 23:49pm
v2
Comments
ZurdoDev 31-May-16 8:04am    
And what is your question?
ramesh arunchalam 1-Jun-16 5:42am    
Sorry for the late,when i click the submit button with blank textbox field,i want show alert or warning massage in browser.can't click without text by user..,
ZurdoDev 1-Jun-16 6:40am    
I know. You already explained that part. And you have code to do what you want so what is your question?
Karthik_Mahalingam 31-May-16 8:56am    
"text skip" meaning tab press or button click ?
ramesh arunchalam 1-Jun-16 5:43am    
Button.,

1 solution

try this, for asp

HTML
<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>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900