Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Is there a script to check if a textfields rawValue contains specific text?
For example: If the rawValue is John Smith
can I script to test of the rawValue contains "Smith"?
¡Resuelto! Ir a solución.
Vistas
Respuestas
Total de me gusta
yep! Javascript has one built in: string.search()
Here's an example:
if (TextField1.rawValue.search("the") != -1) TextField2.rawValue = "yes";
else TextField2.rawValue = "no";
http://www.w3schools.com/jsref/jsref_search.asp
Message was edited by: jasotastic81 added external link to w3's site.
Vistas
Respuestas
Total de me gusta
yep! Javascript has one built in: string.search()
Here's an example:
if (TextField1.rawValue.search("the") != -1) TextField2.rawValue = "yes";
else TextField2.rawValue = "no";
http://www.w3schools.com/jsref/jsref_search.asp
Message was edited by: jasotastic81 added external link to w3's site.
Vistas
Respuestas
Total de me gusta
That's great - thanks.
Your script says to look for the text "the" in textfield1 rawValue
what does the !=-1 mean?
Thanks for the link and your help!
-Don
Vistas
Respuestas
Total de me gusta
Yeah, I just made it something simple. It looks for whatever string is in the ().
If you had a text field that you want to let the user use to search for something, I'm calling it tfQuery, then your if statement could be:
if(TextField1.rawValue.search(tfQuery.rawValue) != -1) ...
The "!= -1" is there because the search function returns "-1" if the string you're searching for isn't found. In my example, I was just checking one field to see if "the" appeared anywhere in it. If search() DOES find something, then it returns the place value of the first letter in the string you searched for.
example:
let TextField1 be "We the people..."
TextField1.rawValue.search("the") returns 3.
Vistas
Respuestas
Total de me gusta
Thanks for your help
-Don
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas