Angular reactive forms validation

Поделиться
HTML-код
  • Опубликовано: 9 фев 2025

Комментарии • 68

  • @MomsMagicPunam
    @MomsMagicPunam 4 года назад

    I like your tutorial very much. Excellent teacher you are . I like your way to describe the things in easy manner.

  • @ayhanexe9455
    @ayhanexe9455 4 года назад

    The best tutorial for angular reactive forms for me. Thanks brother :)

  • @sunpreetsingh5143
    @sunpreetsingh5143 6 лет назад +9

    for those who are using bootstrap 4 ..can use "alert alert-danger" instead of "has-error"

  • @simonkalu
    @simonkalu 6 лет назад +1

    You're a great teacher. You made it seem so easy.. Thank you

    • @beginner2expert
      @beginner2expert 5 лет назад

      You can also try this tutorial for more info with some industrial example: ruclips.net/video/Nk3qtkxN7s8/видео.html

  • @mravistm
    @mravistm 4 года назад

    great voice, very pleasant and very well explained

  • @berkanbilgin2287
    @berkanbilgin2287 5 лет назад

    Thanks for another amazing video Kudvenkat. On 10:07, is there any harm to wrap that condition in a function? As far as I see, functions defined in the DOM is called 100s of times based on the value changes on the form so it kind of bothered me. But I wonder if the same thing happens for even if we use just like you did on the dirty and touched and error checks via form control itself?

  • @ankitaverma2271
    @ankitaverma2271 3 года назад +2

    My this part of validation is not working and displays the error message Object is possibly null .

  • @syedakhil9818
    @syedakhil9818 6 лет назад +3

    in password validation how to set minimum one upper-case & one lower-case & one special character...? can you please add it in this video....

  • @randhirkumar3705
    @randhirkumar3705 6 лет назад

    Why are you not using bootstrap 4 in your latest tutorials ?

  • @namratabagh3311
    @namratabagh3311 3 года назад

    I am confused how to do validation in nested form builder from html side. How to get the errors please let me know

  • @manojgp1991
    @manojgp1991 5 лет назад

    Sir , I am new in Angular and I want to use drag and drop form builder like bootstrap form builder , please help me as soon as possible

  • @ymtan
    @ymtan 6 лет назад

    Hi Venkat,
    I would like to clarify with you regarding the following boolean expression. If the Full Name form control is empty on the initial page load or if we did not supply a valid value for the Full Name form control, then the errors property on the Full Name form control will return true. Am I correct ?
    employeeForm.get('fullName').errors
    Best regards.
    Edward

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  6 лет назад

      No "employeeForm.get('fullName').errors" does not return true or false.
      It returns either NULL or ValidationErrors object. If it returns NULL, then it means on the fullName formcontrol there are no validation errors. If it returns a ValidationErrors object then that means there are validation errors.
      Hope this answers your question.

    • @ymtan
      @ymtan 6 лет назад

      If that is the case, how the following boolean expression works with either NULL or ValidationErrors object ???
      [ngClass]="{'has-error': ((employeeForm.get('fullName').touched ||
      employeeForm.get('fullName').dirty) &&
      employeeForm.get('fullName').errors)

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  6 лет назад

      In addition to true and false, there is also truthy and falsy.
      All the following values evaluates to a falsy value in a boolean context
      false
      '' or "" Empty string, i.e a pair of single or double quotes with nothing in between them
      NaN i.e Not a Number
      0
      null
      undefined
      Everything else, like the following values evaluates to a truthy value in a boolean context
      true
      []- an empty array
      {} - an empty object
      15 - Number other than ZERO
      'SomeString' - Some string value, other than an empty string
      So in our case if the following statement returns NULL, it evaluates to falsy value because it is used in a boolean context. So the has-error class is not added.
      employeeForm.get('fullName').errors
      On the other hand, if the following statement returns a ValidationErrors object, it evaluates to truthy value because it is used in a boolean context. So it adds the has-error class.
      employeeForm.get('fullName').errors

    • @ymtan
      @ymtan 6 лет назад

      So in our case if the Full Name field or form control is empty, the "employeeForm.get('fullName').errors" statement returns a ValidationErrors object, which will evaluate to truthy value.
      On the other hand, if the Full Name field or form control is not empty, the "employeeForm.get('fullName').errors" statement returns NULL, which will evaluate to falsy value.
      Is my understanding correct ???

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  6 лет назад

      You got it.

  • @sandeepchegu4655
    @sandeepchegu4655 6 лет назад

    hi venkat sir good evening
    in this tutorial i have a problem with displaying the validation error message like
    "full name must me 2 characters and less than 10 characters" was not displayed
    when we type the full name more than 10 characters its become error but the error message is not displayed after the text box
    please guide me how to get this.
    thank you.

    • @mausamsinghthakuri2965
      @mausamsinghthakuri2965 6 лет назад

      use this fullName: ['', [Validators.required, Validators.minLength(2), Validators.maxLength(10)]],

    • @akwac83
      @akwac83 5 лет назад

      Hi Sandeep, did you figure this out? I'm having the same problem.

    • @akwac83
      @akwac83 5 лет назад

      NM, worked out, I was using camel case in the html for checking min/max length and so even though there were errors, they were not being caught be the *ngIf check for this span.

  • @anywheredoor4699
    @anywheredoor4699 6 лет назад

    sir for example consider if we are entering 3 chars there are no errors hence the errors returns null and console throws error cannot read property required of null

  • @arjunsunny999
    @arjunsunny999 4 года назад

    Thank you

  • @saadmumbasit
    @saadmumbasit 4 года назад

    hello sir i need to validate mat-select field using form group used your approach but when is use validation on mat-select field react on 2nd click that is my code


    {{ country.viewValue }}


    Please select your country

    {{formErrors.country}}

  • @shivambajpai523
    @shivambajpai523 5 лет назад

    This is a great tutorial. I have a Question. I have my form working the same way as yours do. But when I submit the form ignoring the error shown, it gets submitted. So what is the point of showing this field validation if i have to check the fields on submit function weather they are empty or not? Or is there something I am missing?

    • @VIjayKumartheh2o
      @VIjayKumartheh2o 5 лет назад +1

      then please use [disable] = !form.valid for the submit button

  • @lehung1778
    @lehung1778 6 лет назад

    Thanks for your tutorials.

    • @beginner2expert
      @beginner2expert 5 лет назад

      You can also try this tutorial for more info with some industrial example: ruclips.net/video/Nk3qtkxN7s8/видео.html

  • @anywheredoor4699
    @anywheredoor4699 6 лет назад +3

    for min length and max length the console says cannot read property minlength of null

    • @hnkdln7307
      @hnkdln7307 5 лет назад

      I guess u have not used a [ ] for validators , i mean :
      fullname: [ '' , [Validators.required, Validators.minLength(2), Validators.maxLength(10)] ]

  • @TapanDubey
    @TapanDubey 4 года назад

    Nice Video , Thank you for sharing #TapanDubey

  • @yogithayogi7718
    @yogithayogi7718 3 года назад

    Im getting error as object is null in the empform. Get('fullname'). errors can anyone help me

  • @meenapandi2326
    @meenapandi2326 4 года назад

    can anyone please tell me what is the difference between angular tutorial and angular curd tutorial of him.which one i need to start learn

    • @pranjalevince9371
      @pranjalevince9371 4 года назад +1

      For basics understanding start first Angular 2 tutorials, After that start Angular CRUD tutorials which will clear all the concepts and basics after that start Angular 6 Tutorials

    • @meenapandi2326
      @meenapandi2326 4 года назад

      @@pranjalevince9371 Thank you

  • @jaykrish6118
    @jaykrish6118 4 года назад

    For me Validators is not working What is the Problem im using BS4 version

  • @vgaming114
    @vgaming114 4 года назад

    nice tutorial. I learned something from you. but , in your html, typing the same conditions many times is ugly, you have to refactor.

  • @dhananjaysahare7312
    @dhananjaysahare7312 5 лет назад

    sir aap ne html page me table tage me jo coding ki hai uska code to bataye hi nhi jisse run karne par table so nhi ho rhi hai

    • @beginner2expert
      @beginner2expert 5 лет назад

      You can also try this tutorial for more info with some industrial example: ruclips.net/video/Nk3qtkxN7s8/видео.html

  • @deepakbaghela8130
    @deepakbaghela8130 6 лет назад

    good tutorials

  • @belmiris1371
    @belmiris1371 6 лет назад

    Thank you very much for this! I think a more accurate error message would be 'Full Name must be greater than 1 character and less than 11 characters'.

  • @siyandakhanyile210
    @siyandakhanyile210 5 лет назад

    I am getting this error ERROR TypeError: Cannot read property 'get' of undefined

  • @voicelesssoul
    @voicelesssoul 6 лет назад

    Your voice is completely changed, when I hear it in SQL server which is 6 years back.

  • @mohanrajraja2896
    @mohanrajraja2896 5 лет назад

    what is the difference between isTouched and isDirty

  • @sri94aa1
    @sri94aa1 5 лет назад

    Will Bootstrap 4 work with this ?

    • @Jenniferab32
      @Jenniferab32 5 лет назад +1

      Use is-invalid instead of has-error and also for some reason I needed to attached the ng-class to the input instead of the label as he does here. If anyone knows why I'd love to understand that.

    • @Jenniferab32
      @Jenniferab32 5 лет назад +1

      First Name

      Please enter your First Name

    • @sri94aa1
      @sri94aa1 5 лет назад

      Thank you

  • @dattabadhe6759
    @dattabadhe6759 5 лет назад

    HI guys , I got Cannot read property 'touched' of null error

  • @dracomalfoy1245
    @dracomalfoy1245 4 года назад

    if Validators.required is a method , then why are you not using parenthesis () ?

  • @ekoveadvisor2854
    @ekoveadvisor2854 4 года назад

    year to year programming language seems to be more painful than it was.

  • @anywheredoor4699
    @anywheredoor4699 6 лет назад +1

    for errors.required it says cannot read property of null

    • @Bettertodo23
      @Bettertodo23 6 лет назад +1

      stackoverflow.com/questions/45431489/async-custom-validation-causes-an-error-to-the-console-cannot-read-property-r

    • @digambarshinde5405
      @digambarshinde5405 5 лет назад

      @@Bettertodo23 Cannot read property 'touched' of null

    • @usmansaleh9721
      @usmansaleh9721 5 лет назад

      @sahil use '?' like errors?.required

  • @ErkanOkman
    @ErkanOkman 6 лет назад

    👍👏

  • @SAAMY_1414
    @SAAMY_1414 4 года назад

    This validators give error
    For that I used
    Validators.compose([Validators.required, Validators.minLength(3),Validators.maxLength(10)])

  • @patrickmarckdulaca634
    @patrickmarckdulaca634 5 лет назад

    if your "Fullname
    must not be lower than 2 and higher than 10 characters" is not displaying. Try changing the employeeForm.get('fullName').errors?.minLength into employeeForm.get('fullName').errors?.minlength and the same to the maxLength. Goodluck

  • @shirjeelkhan
    @shirjeelkhan 6 лет назад

    Hello sir, good tutorial with great efforts. Please make a tutorial or udemy series on ionic 3/4 framework.

  • @mrandmrspunekar
    @mrandmrspunekar 5 лет назад

    Hi Sir,
    I got error ERROR TypeError: "_co.formbuilder.get is not a function