jquery disable button - Web Development and Web Design Codes

Latest

Saturday, February 17, 2018

jquery disable button

jquery disable button

jquery disable button
jquery disable button
Hi friends today we are going to learn how to disable and enable submit button when input fields are empty and filled..
Follow the below jquery enable disable button example.

index.html
<html>
    <title>Jquery Disable, Enable Button by CodeNair</title>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript">
   function inputtext()
        {
            if ($("#textBox").val() == "") {
                 $('#submit').attr("disabled", "disabled");
            }else{
   $('#submit').removeAttr("disabled");
   }
        }
        function call()
        {
            alert("Wellcome To CodeNair.com");
        }   
</script>
</head>
<body> 
<center><b>Jquery Disable, Enable Button CodeNair</b></center><br>
<table align="center" cellspacing="0">
    <tr>
    <td>Enter Text:</td>
    <td><input type="text" id="textBox" onkeyup='inputtext(this)' maxlength=15/></td>
 </tr>
 <tr>
    <td></td>
    <td><input id="submit" type="submit" value="Click" disabled="disabled" name='sub' onclick='call()'/></td>
 </tr>
</table>
</body>
</html>

That's it friends how disable and enable submit button in jquery..
.stay with us for more codes..thank you..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.