Angular 2 - Form is invalid when browser autofill

前端 未结 7 1944
广开言路
广开言路 2021-01-31 16:48

I have a Login Form which has email and password fields.

I\'ve chosen for browser autofill.

The problems is: When browser autofills login form, both fields are p

7条回答
  •  借酒劲吻你
    2021-01-31 17:32

    this is not the best practice for code but it will work for sure-

    if you are having two way binding then its very easy task just check for length of both textbox if it is greater then zero then return false else return true and call the method in disabled attribute. Method-

        validcheck() {
             return username.length <= 0 || password.length <= 0;     
        }
    

    and call the method inside button disabled attribute

        
    

提交回复
热议问题