jQuery UI Widgets Forums General Discussions I want to discuss: Editor. Thanks for any advice!

This topic contains 1 reply, has 2 voices, and was last updated by  admin 10 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • krishna_jp
    Participant

    Is there a recommended approach for integrating Angular forms validation with jqxEditor content?


    admin
    Keymaster

    Hi,

    Yes, you can do this

    
    <form #form="ngForm" (ngSubmit)="onSubmit()">
      <jqxEditor
        #editor
        [width]="'600px'"
        [height]="'200px'"
        [(ngModel)]="content"
        name="content"
        required>
      </jqxEditor>
    
      <div *ngIf="!content && form.submitted" style="color:red;">
        Content is required
      </div>
    
      <button type="submit">Submit</button>
    </form>

    and

    import { Component } from '@angular/core';
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html'
    })
    export class AppComponent {
      content = '';
    
      onSubmit() {
        if (!this.content) {
          console.log('Validation failed: content is empty');
        } else {
          console.log('Form submitted with:', this.content);
        }
      }
    }

    make sure to import the Editor like this:

    import { jqxEditorModule } from 'jqwidgets-ng/jqxeditor';

    Best regards,
    Peter Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.