Angular Form validator only works when typing in text box
up vote
0
down vote
favorite
I am developing a small app in angular5 with PHP. I have an issue in validating form. Form validator works fine when I input data by typing in keyboard. But it is not working when I fill data with javascript.
For example
In email field,
If I type myemail
, Its showing invalid email. works good.
But If I set using javascript like $('#email').value('asdsa@gmail.com')
its not working.
What is wrong? I am new to Angular5.
javascript html angular
add a comment |
up vote
0
down vote
favorite
I am developing a small app in angular5 with PHP. I have an issue in validating form. Form validator works fine when I input data by typing in keyboard. But it is not working when I fill data with javascript.
For example
In email field,
If I type myemail
, Its showing invalid email. works good.
But If I set using javascript like $('#email').value('asdsa@gmail.com')
its not working.
What is wrong? I am new to Angular5.
javascript html angular
3
instead of directly manipulating DOM, try setting value ofform control
manuallythis.registerForm.controls['email'].setValue('example@abc.com')
– Sarthak Aggarwal
Nov 13 at 6:57
What u mean? How?
– Banujan Balendrakumar
Nov 13 at 6:59
Please paste your code as text instead of screen shot
– Amit Chigadani
Nov 13 at 7:05
Sarthak Aggarwal
Works thanks.
– Banujan Balendrakumar
Nov 13 at 7:06
angular.io/api/forms/AbstractControl#updatevalueandvalidity
– Eliseo
Nov 13 at 7:34
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am developing a small app in angular5 with PHP. I have an issue in validating form. Form validator works fine when I input data by typing in keyboard. But it is not working when I fill data with javascript.
For example
In email field,
If I type myemail
, Its showing invalid email. works good.
But If I set using javascript like $('#email').value('asdsa@gmail.com')
its not working.
What is wrong? I am new to Angular5.
javascript html angular
I am developing a small app in angular5 with PHP. I have an issue in validating form. Form validator works fine when I input data by typing in keyboard. But it is not working when I fill data with javascript.
For example
In email field,
If I type myemail
, Its showing invalid email. works good.
But If I set using javascript like $('#email').value('asdsa@gmail.com')
its not working.
What is wrong? I am new to Angular5.
javascript html angular
javascript html angular
asked Nov 13 at 6:55
Banujan Balendrakumar
274110
274110
3
instead of directly manipulating DOM, try setting value ofform control
manuallythis.registerForm.controls['email'].setValue('example@abc.com')
– Sarthak Aggarwal
Nov 13 at 6:57
What u mean? How?
– Banujan Balendrakumar
Nov 13 at 6:59
Please paste your code as text instead of screen shot
– Amit Chigadani
Nov 13 at 7:05
Sarthak Aggarwal
Works thanks.
– Banujan Balendrakumar
Nov 13 at 7:06
angular.io/api/forms/AbstractControl#updatevalueandvalidity
– Eliseo
Nov 13 at 7:34
add a comment |
3
instead of directly manipulating DOM, try setting value ofform control
manuallythis.registerForm.controls['email'].setValue('example@abc.com')
– Sarthak Aggarwal
Nov 13 at 6:57
What u mean? How?
– Banujan Balendrakumar
Nov 13 at 6:59
Please paste your code as text instead of screen shot
– Amit Chigadani
Nov 13 at 7:05
Sarthak Aggarwal
Works thanks.
– Banujan Balendrakumar
Nov 13 at 7:06
angular.io/api/forms/AbstractControl#updatevalueandvalidity
– Eliseo
Nov 13 at 7:34
3
3
instead of directly manipulating DOM, try setting value of
form control
manually this.registerForm.controls['email'].setValue('example@abc.com')
– Sarthak Aggarwal
Nov 13 at 6:57
instead of directly manipulating DOM, try setting value of
form control
manually this.registerForm.controls['email'].setValue('example@abc.com')
– Sarthak Aggarwal
Nov 13 at 6:57
What u mean? How?
– Banujan Balendrakumar
Nov 13 at 6:59
What u mean? How?
– Banujan Balendrakumar
Nov 13 at 6:59
Please paste your code as text instead of screen shot
– Amit Chigadani
Nov 13 at 7:05
Please paste your code as text instead of screen shot
– Amit Chigadani
Nov 13 at 7:05
Sarthak Aggarwal
Works thanks.– Banujan Balendrakumar
Nov 13 at 7:06
Sarthak Aggarwal
Works thanks.– Banujan Balendrakumar
Nov 13 at 7:06
angular.io/api/forms/AbstractControl#updatevalueandvalidity
– Eliseo
Nov 13 at 7:34
angular.io/api/forms/AbstractControl#updatevalueandvalidity
– Eliseo
Nov 13 at 7:34
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
try to use below code for setting up the value in the form control. pleas refer angular doc for more information https://angular.io/guide/form-validation
https://angular.io/guide/reactive-forms
https://angular.io/api/forms/FormControl
this.registerForm.controls.email.setValue('asdsa@gmail.com');
add a comment |
up vote
0
down vote
You can just say see this link
this.registerForm.patchValue({
email: 'asdsa@gmail.com'
});
or you can assign it initially while creating a form like,
this.registerForm = this.fb.group({
email: ['asdsa@gmail.com']
})
add a comment |
up vote
0
down vote
If I remember correctly, angular does not know when jQuery affects the Physical DOM(therefore not knowing when to run its check on variables to cause a change). In order to do this, you have to initiate a change cycle to angular after your jquery action.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
try to use below code for setting up the value in the form control. pleas refer angular doc for more information https://angular.io/guide/form-validation
https://angular.io/guide/reactive-forms
https://angular.io/api/forms/FormControl
this.registerForm.controls.email.setValue('asdsa@gmail.com');
add a comment |
up vote
1
down vote
accepted
try to use below code for setting up the value in the form control. pleas refer angular doc for more information https://angular.io/guide/form-validation
https://angular.io/guide/reactive-forms
https://angular.io/api/forms/FormControl
this.registerForm.controls.email.setValue('asdsa@gmail.com');
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
try to use below code for setting up the value in the form control. pleas refer angular doc for more information https://angular.io/guide/form-validation
https://angular.io/guide/reactive-forms
https://angular.io/api/forms/FormControl
this.registerForm.controls.email.setValue('asdsa@gmail.com');
try to use below code for setting up the value in the form control. pleas refer angular doc for more information https://angular.io/guide/form-validation
https://angular.io/guide/reactive-forms
https://angular.io/api/forms/FormControl
this.registerForm.controls.email.setValue('asdsa@gmail.com');
answered Nov 13 at 7:00
Ajay Ojha
94027
94027
add a comment |
add a comment |
up vote
0
down vote
You can just say see this link
this.registerForm.patchValue({
email: 'asdsa@gmail.com'
});
or you can assign it initially while creating a form like,
this.registerForm = this.fb.group({
email: ['asdsa@gmail.com']
})
add a comment |
up vote
0
down vote
You can just say see this link
this.registerForm.patchValue({
email: 'asdsa@gmail.com'
});
or you can assign it initially while creating a form like,
this.registerForm = this.fb.group({
email: ['asdsa@gmail.com']
})
add a comment |
up vote
0
down vote
up vote
0
down vote
You can just say see this link
this.registerForm.patchValue({
email: 'asdsa@gmail.com'
});
or you can assign it initially while creating a form like,
this.registerForm = this.fb.group({
email: ['asdsa@gmail.com']
})
You can just say see this link
this.registerForm.patchValue({
email: 'asdsa@gmail.com'
});
or you can assign it initially while creating a form like,
this.registerForm = this.fb.group({
email: ['asdsa@gmail.com']
})
edited Nov 13 at 7:07
answered Nov 13 at 7:01
Abhishek Ekaanth
882923
882923
add a comment |
add a comment |
up vote
0
down vote
If I remember correctly, angular does not know when jQuery affects the Physical DOM(therefore not knowing when to run its check on variables to cause a change). In order to do this, you have to initiate a change cycle to angular after your jquery action.
add a comment |
up vote
0
down vote
If I remember correctly, angular does not know when jQuery affects the Physical DOM(therefore not knowing when to run its check on variables to cause a change). In order to do this, you have to initiate a change cycle to angular after your jquery action.
add a comment |
up vote
0
down vote
up vote
0
down vote
If I remember correctly, angular does not know when jQuery affects the Physical DOM(therefore not knowing when to run its check on variables to cause a change). In order to do this, you have to initiate a change cycle to angular after your jquery action.
If I remember correctly, angular does not know when jQuery affects the Physical DOM(therefore not knowing when to run its check on variables to cause a change). In order to do this, you have to initiate a change cycle to angular after your jquery action.
answered Nov 13 at 7:14
Minh Nguyen
645
645
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275415%2fangular-form-validator-only-works-when-typing-in-text-box%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
instead of directly manipulating DOM, try setting value of
form control
manuallythis.registerForm.controls['email'].setValue('example@abc.com')
– Sarthak Aggarwal
Nov 13 at 6:57
What u mean? How?
– Banujan Balendrakumar
Nov 13 at 6:59
Please paste your code as text instead of screen shot
– Amit Chigadani
Nov 13 at 7:05
Sarthak Aggarwal
Works thanks.– Banujan Balendrakumar
Nov 13 at 7:06
angular.io/api/forms/AbstractControl#updatevalueandvalidity
– Eliseo
Nov 13 at 7:34