Moti Mashiah
asked on
Jquery keyup
Hi Guys,
can somebody tell how to write this jquery code:
I have a textbox and when user type in the textbox I would like to disable button and when something written in I would like to enable the button:
here is my example:
can somebody tell how to write this jquery code:
I have a textbox and when user type in the textbox I would like to disable button and when something written in I would like to enable the button:
here is my example:
$(document).ready(function () {
$("#textmanufactureid").keyup(function () {
if (this != "") {
$("#activate-step-7").removeAttr('disabled');
} else {
$("#activate-step-7").attr('disabled', 'disabled');
}
});
});
Use Prop();
Sample code:
Sample code:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input").keyup(function(){
// alert(this.value.length);
if(this.value.length == 0)
$("#button").prop('disabled', true);
else
$("#button").prop('disabled', false);
});
});
</script>
</head>
<body>
Enter your name: <input id="textf" type="text" >
<button id="button" disabled> test </button>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yep basically it was kinda of what you said.
thanks,
thanks,
ASKER
I got the point it works now.
Open in new window
The issue actually was in the script file for some reason when I put this code on my script file "test.js" if doesn't work but when I put it on the html page itself it works.
you guys have idea why?
I can see the script file in the inspection at the browser.