0👍
try this,
wrote a sample function .. by default it will be disabled, if you write something button will enable. no jquery used native javascript
document.getElementById("next").disabled = true;
function do_enable(e=true) {
if (e)
{
alert("Success")
/*vm.pid=e.pid;
console.log(vm.pid);*/
document.getElementById("next").disabled = false;
}
else {
vm.response = e;
alert("Registration Failed")
}
}
<input type="text" id="status" onchange="do_enable()" placeholder="say something">
<button type="submit" id="next" class='btn btn-next btn-primary' name='next' value='Next'>Next</button>
- [Vuejs]-Counter not incrementing by 1 – Vue
- [Vuejs]-Reset a const variable to its default value in vue
0👍
Use :disabled
to enable or disable button using Vue. Read more.
<button type="submit" class='btn btn-next btn-primary' name='next' value='Next' :disabled="isDisabled">Next</button>
success: function(e) {
if (e.status)
{
alert("Success")
vm.pid=e.pid;
console.log(vm.pid);
vm.isDisabled = false; //enable button
}
else {
vm.response = e;
vm.isDisabled = true; //disable button
alert("Registration Failed")
}
}
Update:
Don’t forget to add isDisabled
in vue data
object
data: {
isDisabled: false
}
- [Vuejs]-How can I wait until a variable is available?
- [Vuejs]-"SyntaxError: Unexpected identifier" when runnning a Nuxt.js project
0👍
do this
success: function(e) {
if (e.status) {
alert("Success")
vm.pid = e.pid;
console.log(vm.pid);
} else {
vm.response = e;
alert("Registration Failed")
e.preventDefault();//do this it can prevent your from to next tab
}
}
- [Vuejs]-2 way binding : A practical example
- [Vuejs]-Cordova will not open iframe target links in system browser (or at all)
Source:stackexchange.com