Enable/Disable Button According To Textbox Value Using Java Script
In this article, we are disable
the button when textbox value is null if textbox have some then we are enable.
Mainly we need this code when we want to that no one fire the event without enter
the textbox value.
Source Code:-
<html>
<head runat="server">
<title>Enable/Disable
Button According To Textbox Value</title>
<script type="text/javascript">
$(document).ready(function () {
$('input[type="submit"]').prop('disabled', true);
$('input[type="text"]').keyup(function () {
if
($(this).val() != '')
{
$('input[type="submit"]').prop('disabled', false);
}
});
});
</script>
</head>
<body>
<fieldset style="width: 350px;" align="center">
<legend>Enable/Disable
Button According To Textbox Value </legend>
<input id="Text2" type="text" style="border-color: Maroon" placeholder=" Name *" />
<input id="Text1" type="text" style="border-color: Maroon" placeholder=" Mobile Number *" />
<br />
<br />
<input type="submit" value="Send" style="border-color: Maroon; width: 150px;" />
</fieldset>
</body>
</html>
Out-Put:-
Enable/Disable Button According To Textbox Value Using Java Script
Reviewed by NEERAJ SRIVASTAVA
on
11:39:00 AM
Rating:
No comments: