rajasabhai rajasabhai
How to check for a phrase on a string using scripts in events
eg. I have a text box and I have to validate a particular text is not entered on the input. Can you provide me with how to look for in the onChange event?
I should not allow Hello, if Hello is entered I will alert the user.
Text : ” Hello! welcome world.”
If above is user input I have to throw an alert to the user, as t contains <Hello>
Thanks in advance.
rajasabhai rajasabhai
thanks all.. here is the solution i attempted
me.getText().indexOf(“Hello”)> -1;
to achieve the same. Thanks.
SPARK Support
Hi Rajasabhai,
The Text control provides the context variables newText and oldText to the On Change event.
You may wish to try using the On Input event with the context variables of current and potential.
Please see our article on the Text control indicating which context variables are available to each event:
https://support.salientprocess.com/docs/enterprise/Text.html
As for the method to check for position of the first occurrence of a specified value in a string, please see the following article:
https://www.w3schools.com/jsref/jsref_indexof.asp
Regards,
Stephen P.