Skip to content

Commit

Permalink
Prevent input text boxes with HTML and javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
venkykandagaddala committed Aug 28, 2024
1 parent 7de6df5 commit 4c3003e
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 286 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@
createEventForm?.controls['description'].errors?.required">
Description is mandatory
</mat-error>
<mat-error [hidden]="false" i18n="description Error|Explains description is required"
i18n-aria-label aria-label="description Error|Explains description is required "
*ngIf="createEventForm?.controls['description']?.touched &&
createEventForm?.controls['description'].errors?.noHtml">
HTML and javascript is not allowed
</mat-error>
<mat-hint>{{description.value.length}}/1000 characters</mat-hint>
</mat-form-field>
</div>
Expand All @@ -149,6 +155,10 @@
*ngIf="createEventForm?.controls['agenda']?.touched && createEventForm?.controls['agenda'].errors?.required">
Agenda is mandatory
</mat-error>
<mat-error [hidden]="false"
*ngIf="createEventForm?.controls['agenda']?.touched && createEventForm?.controls['agenda'].errors?.noHtml">
HTML and javascript is not allowed
</mat-error>
<mat-hint>{{agenda.value.length}}/500 characters</mat-hint>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MomentDateAdapter } from '@angular/material-moment-adapter'
import _ from 'lodash'
import { TelemetryEvents } from '../../events/model/telemetry.event.model'
import { ProfileV2UtillService } from '../services/home-utill.service'
import { preventHtmlAndJs } from '../../../validators/prevent-html-and-js.validator'
/* tslint:enable */

export const MY_FORMATS = {
Expand Down Expand Up @@ -146,8 +147,8 @@ export class CreateEventComponent implements OnInit {
eventPicture: new FormControl('', [Validators.required]),
eventTitle: new FormControl('', [Validators.required]),
// summary: new FormControl('', [Validators.required]),
description: new FormControl('', [Validators.required]),
agenda: new FormControl('', []),
description: new FormControl('', [Validators.required, preventHtmlAndJs()]),
agenda: new FormControl('', [preventHtmlAndJs()]),
// isItKarmayogiTalk: new FormControl('', []),
eventType: new FormControl('', [Validators.required]),
eventDate: new FormControl('', [Validators.required]),
Expand Down Expand Up @@ -580,7 +581,7 @@ export class CreateEventComponent implements OnInit {
this.dialogRef.afterClosed().subscribe(() => {
setTimeout(() => {
this.router.navigate([`/app/home/events`])
}, 700)
}, 700)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@
<mat-error [hidden]="false" i18n="description Error|Explains description is required"
i18n-aria-label aria-label="description Error|Explains description is required "
*ngIf="createEventForm?.controls['description']?.touched &&
createEventForm?.controls['description'].errors?.required">
createEventForm?.controls['description'].errors?.required">
Description is mandatory
</mat-error>
<mat-error [hidden]="false" i18n="description Error|Explains description is required"
i18n-aria-label aria-label="description Error|Explains description is required "
*ngIf="createEventForm?.controls['description']?.touched &&
createEventForm?.controls['description'].errors?.noHtml">
HTML and javascript is not allowed
</mat-error>
<mat-hint>{{description.value.length}}/1000 characters</mat-hint>
</mat-form-field>
</div>
Expand All @@ -155,6 +161,10 @@
*ngIf="createEventForm?.controls['agenda']?.touched && createEventForm?.controls['agenda'].errors?.required">
Agenda is mandatory
</mat-error>
<mat-error [hidden]="false"
*ngIf="createEventForm?.controls['agenda']?.touched && createEventForm?.controls['agenda'].errors?.noHtml">
HTML or Js is not allowed
</mat-error>
<mat-hint>{{agenda.value.length}}/500 characters</mat-hint>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import _ from 'lodash'
import { TelemetryEvents } from '../model/telemetry.event.model'
import { ProfileV2UtillService } from '../services/home-utill.service'
import { MomentDateAdapter } from '@angular/material-moment-adapter'
import { preventHtmlAndJs } from '../../../validators/prevent-html-and-js.validator'
/* tslint:enable */

export const MY_FORMATS = {
Expand Down Expand Up @@ -151,8 +152,8 @@ export class EditEventComponent implements OnInit {
eventPicture: new FormControl('', [Validators.required]),
eventTitle: new FormControl('', [Validators.required]),
// summary: new FormControl('', []),
description: new FormControl('', [Validators.required]),
agenda: new FormControl('', []),
description: new FormControl('', [Validators.required, preventHtmlAndJs()]),
agenda: new FormControl('', [preventHtmlAndJs()]),
// isItKarmayogiTalk: new FormControl('', []),
eventType: new FormControl('', [Validators.required]),
eventDate: new FormControl('', [Validators.required]),
Expand Down Expand Up @@ -574,7 +575,7 @@ export class EditEventComponent implements OnInit {
this.displayLoader = false
this.openSnackbar('Event details are successfuly updated.')
this.router.navigate([`/app/home/events`])
}, 5000)
}, 5000)
}
},
(err: any) => {
Expand Down
Loading

0 comments on commit 4c3003e

Please sign in to comment.