简体   繁体   中英

Button remain disabled even when input field with type=“emali” not empty

I have a form with input type="email". Now I need the submit button to be disabled until the input field is empty, however if the user enters anything the button should be enabled. Using ng-disabled on the button, but the problem is that the button remains disabled even after I enter something into the field and remains disabled until I enter a valid email id. My guess that the html5 validation occurs before the angular js functionality can evoke or something like that.

<input type="email" class="span3"   name="emailValue" ng-model="emailValue">
<button class="btn " type="button" ng-click="submit()" ng-disabled="!emailValue"> 

Any kind of help is deeply appreciated. I'm new to front end so i'm lost as in where to look for.

try

<button class="btn " type="button" ng-click="submit()" ng-disabled="emailValue==''">

that should work

................................................

You have to be sure it's a falsy value first. Simple

$scope.emailValue = ''; 

in the corresponding controller will do the trick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM