2 Replies Latest reply on May 10, 2017 9:10 AM by Ed Rayyis

    Check a text field in a form for acceptable URL's

    Ed Rayyis



      I have a Marketo form with one field called sharedURL. I set this as a text field because the URL field is too restrictive, as you may have guest it is a field which allows people to input a URL. The field should only accept certain domains before moving on to the defined Landing page. Lets assume the only acceptable domains are www.marketo.com, http://www.marketo.com, https://www.marketo.com etc (all variations of the domain). I looked at multiple suggested solutions on various external sites and marketo sites but couldnt manage to tweak the code to fit my requirement. This is what I got (inserted in the HTML in a guided landing page template) my Form and field details are (if its needed). My solution did not work... any help appreciated....





      (function (){

      // Please include the url domains you would like to block in this list

      var validDomains = [







      MktoForms2.whenReady(function (form){


      var url = form.vals().sharedURL;


      if(!isurlGood(url)) {


      var urlElem = form.getFormElem().find("#sharedURL");

      form.showErrorMessage("You must use an approved Domain.", urlElem);







      function isurlGood(url) {

      for(var i=0; i < validDomains.length; i++) {

      var domain = validDomains[i];

      if (url.indexOf(domain) != -1) {

      return false;



      return true;