Last active
December 3, 2019 21:48
-
-
Save sfmishra/11209e7ec9565c9b330d440fa6ee7524 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement } from 'lwc'; | |
export default class lwcInput extends LightningElement { | |
handleChange(event) { | |
let inputCompValue = event.target.value; | |
let inputComp = this.template.querySelector('.inputComp'); | |
let splChars = /[0-9(@!#\$%\^\&*\)\(+=._-]/; | |
if(inputCompValue.match(splChars)) { | |
inputComp.setCustomValidity("Only character allowed."); | |
inputComp.reportValidity(); | |
} else { | |
inputComp.setCustomValidity(''); | |
inputComp.reportValidity(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment