Catalog Item - Variable Contains / Contains - Client Script

alexcharleswort
Tera Expert

Hey guys,

I have a need for a string variable (tra_course0) to contain a "$" in the user's input. I can't seem to quite get the syntax right on how to get a catalog client script to read the input, search for the "$" at the beginning and if it's not included to alert them to include it. Any ideas? Ideally I want the input to START WITH the $ but if nothing else I would like it to CONTAIN the $.

Thanks in advance for you assistance!

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

You have a javascript method called startsWith() for this. Use that, you code will look like this


JavaScript String startsWith() Method


if(!g_form.getValue('field name').startsWith("$")){


alert("message goes here");


}


View solution in original post

5 REPLIES 5

Abhinay Erra
Giga Sage

So you want to validate a text field to see if it stats with "$" right?


That is correct!


Abhinay Erra
Giga Sage

You have a javascript method called startsWith() for this. Use that, you code will look like this


JavaScript String startsWith() Method


if(!g_form.getValue('field name').startsWith("$")){


alert("message goes here");


}


I was trying to mess with 'contains'.. 😕 now I realize I was needing to use 'includes'. But this is exactly what I wanted.



That worked perfectly!



Thanks!!