Website URL validation

Hi, I noticed that there is no validation on contact's property "Website URL". So basically, if somebody fill this field with "roihunter" instead of "roihunter.com" it will get through anyways. Is is possible to set up validation so that only domain names will get through? Thank you

HubSpot updates
2 Replies
bruny
New Contributor

Yes! i would love it if there was a website validation function on this specific property. 

jlozovei
Occasional Contributor

Most people puts the forms inside pages using COS modules - not using JS Forms API. When you use the API to create those forms, you have access to a "submit callback", as explained here.

 

It would be great if HubSpot dev team include a simple validation to check the URL pattern - even because in email fields a similar validation happens.

 

I've created a simple workaround for this issue, using jQuery:

var urlPattern = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/

$('document').on('keydown', 'input[name$="site"]', function(event){
  if(!urlPattern.test($(this).val().toLowerCase())) //wrong value - block form submission
  else //correct value - do stuff
})

 

But, not everybody which uses HubSpot would know how to do it or would have a front-end developer to create this kind of stuff. Also, I this kind of thing is CMS' responsability.