| Index: chrome/browser/ui/views/payments/validating_textfield.cc
|
| diff --git a/chrome/browser/ui/views/payments/validating_textfield.cc b/chrome/browser/ui/views/payments/validating_textfield.cc
|
| index fe3d02d22062309f6ae8205ee86349fdf68d66d0..2a60dd69479fcf8ded12f1cf36cf0324daa178c8 100644
|
| --- a/chrome/browser/ui/views/payments/validating_textfield.cc
|
| +++ b/chrome/browser/ui/views/payments/validating_textfield.cc
|
| @@ -16,14 +16,11 @@ ValidatingTextfield::~ValidatingTextfield() {}
|
|
|
| void ValidatingTextfield::OnBlur() {
|
| Textfield::OnBlur();
|
| + was_blurred_ = true;
|
|
|
| - // The first validation should be on a blur. The subsequent validations will
|
| - // occur when the content changes. Do not validate if the view is being
|
| - // removed.
|
| - if (!was_blurred_ && !being_removed_) {
|
| - was_blurred_ = true;
|
| + // Do not validate if the view is being removed.
|
| + if (!being_removed_)
|
| Validate();
|
| - }
|
| }
|
|
|
| void ValidatingTextfield::ViewHierarchyChanged(
|
| @@ -33,23 +30,17 @@ void ValidatingTextfield::ViewHierarchyChanged(
|
| }
|
|
|
| void ValidatingTextfield::OnContentsChanged() {
|
| - // Validation on every keystroke only happens if the field has been validated
|
| - // before as part of a blur.
|
| - if (!was_blurred_)
|
| - return;
|
| -
|
| + // This is called on every keystroke.
|
| Validate();
|
| }
|
|
|
| bool ValidatingTextfield::IsValid() {
|
| - bool valid = delegate_->IsValidTextfield(this);
|
| - SetInvalid(!valid);
|
| - return valid;
|
| + return delegate_->IsValidTextfield(this);
|
| }
|
|
|
| void ValidatingTextfield::Validate() {
|
| // TextfieldValueChanged may have side-effects, such as displaying errors.
|
| - SetInvalid(!delegate_->TextfieldValueChanged(this));
|
| + SetInvalid(!delegate_->TextfieldValueChanged(this, was_blurred_));
|
| }
|
|
|
| } // namespace payments
|
|
|