If you want to stick partially to your code a quick fix could simply use these:
"^((https?\\://www\\.)|(www\\.))[A-Za-z0-9_\\-]+\\.[A-Za-z0-9_\\-\\%\\&\\?\\.\\=\\+]+$"
(accepts "http://www...." and "www...")
or
"^(https?\\://www\\.)[A-Za-z0-9_\\-]+\\.[A-Za-z0-9_\\-\\%\\&\\?\\.\\=\\+]+$"
(accepts only "http://www...." and NOT "www...")
Neither ones of the above accepts a domain without "www".
Anyway your code (and also the adjusted code I placed above) is WRONG because they would both validate ok domains like these:
Your regex would also accept a crap like this:
To validate just the domain part (forcing www to be entered) you can use this:
var URLReg = /^((https?\://wwww\.)|(www\.))([a-z0-9]([a-z0-9]|(\-[a-z0-9]))*\.)+[a-z]+$/i;
This one won't validate ok crap like:
BTW: It would validate also http://www.domain.com.com but this is not an error because a subdomain url could be like: http://www.subdomain.domain.com and it's valid!
And there is almost no way (or at least no operatively easy way) to validate for proper domain tld with a regex because you would have to write inline into your regex all possible domain tlds ONE BY ONE like this:
var URLReg = /^((https?\://wwww\.)|(www\.))([a-z0-9]([a-z0-9]|(\-[a-z0-9]))*\.)+(com|it|net|uk|de)$/i;
(this last one for instance would validate only domain ending with .com/.net/.de/.it/.co.uk)
New tlds always come out, so you would have to adjust you regex everytimne a new tld comes out, that's odd!
In order to validate also the remaining part of an url you could add the remainig part at the end of the regex:
var URLReg = /^((https?\://wwww\.)|(www\.))([a-z0-9]([a-z0-9]|(\-[a-z0-9]))*\.)+[a-z]+(\/[a-z0-9_\-\%\&\?\.\=\+]*)*$/i
;
It's still not perfect because somone could enter:
http://www.domain.com/????hello
and it would validate ok, but now I'm tired, sorry! :)