function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naresh Krishna.ax1176Naresh Krishna.ax1176 

Website url validation in salesforce

Hi All,


I need to validate the website url which user entered in the apex page.

On salesforce docs, I found Website Extension validation rule (in it only checks for few extensions)

And also it is only to check extension.


Is there any procedure to validate website url in salesforce ?


Can anyone please help me with this.






Try the below code snippet as reference:


<apex:page >



function chkurl()


      var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/

      var urlvalue=document.getElementById('j_id0:j_id2:geturl').value;






      alert('enter a valid url');

      return false


      return true;



<apex:form >

<apex:inputtext id="geturl"/>

<apex:commandButton value="test url" onclick="return chkurl()"/>




Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.