Java Script required to Change on Text input

31 Views Asked by At

I have got a Text box in which, if an input come that Contains "DO NOT PEND". This can be @ the Start or End. There is a Label that get Triggered that Should say "Contact Tier 3".

Contact Tier 3

Not sure what can be used.

1

There are 1 best solutions below

0
On

You need to use JavaScript to attach an event listener to listen for the input event, then use the includes() method to check whether the substring is contained in the input. The method will return true if the substring is found, or false if not.

For example:

document.querySelector('input').addEventListener('input', event => {
  if (event.target.value.includes('DO NOT PEND')) {
    // trigger your label here
  }
})