Tuesday, July 17, 2012

How to check URL contains http using JQuery and RegEx

$("#text_box_url").blur(function() {
  var input = $(this);
  var val = input.val();
  if (val && !val.match(/^http([s]?):\/\/.*/)) {
    input.val('http://' + val);
  }
});

No comments:

Post a Comment