Running a Javascript and Setting State of an element on the basis of the Javascript's Response

Hi All,

We are trying to validate one of our Input boxes to be an URL, I have tried to run a javascript to validate the input box, but i am not sure how to get the result out of the javascript and also to use that result in setting state of an element.

Can someone help me how to execute the full flow

  1. We have an input box which will collect the Url’s
  2. Need to validate this input box for an URL everytime there is a change in input
  3. If invalid, Need to make the input box’s color to change to highlight that it is not valid.

Thanks in Advance

Is there a specific reason you using JavaScript?

Generally speaking when validating if an input value is a valid URL I tend to use Regex as a condition


We dont want to specifically use Javascript, if i can validate the url normally through regex that would do.

Just to check Would this regex validate all sorts of Url.


Also Can you help me in finding out how to use it to validate the input box? do we do it in workflow or in conditions?

various ways… !

This will change the background color of the input if the url is valid

this regex expression would validate those urls

Thanks for sharing this, Would like to know what this regex exactly does.

Because when i try to input a value other than a Url its not throwing an error

Please help me in this

i would suggest doing all the basic tutorials if you are not sure how conditions work… This is simply a condition that turns the input background to a different colour when the input value is seen by the regex expression is valid. If it does not see a valid URL it does nothing! Simply set your condition as you wish… In your case if the URL is not recognised then do something! Run a workflow… Show a notification. Invalidate the input by disabling it. Whatever

@Bubbleboy: Thanks for the explanation here, I was a bit confused if the regex would return a valid URL input or a non valid input.

Later found out that it returns if the URL is valid, Then re framed the conditions to make sure it turns into invalid.

This topic was automatically closed after 70 days. New replies are no longer allowed.