Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
kabir khan
Website Validation(URL)
18 de Fevereiro de 2013 07:18
Resposta

kabir khan

Ranking: New Member

Mensagens: 21

Data de entrada: 15 de Fevereiro de 2013

Mensagens recentes

Hi friends,

My requirement is to validate my form,
I have achieved validation for all things except only one things website validation(url)
.If I give validation for url means it only accepted the website start by eg:http(http:www.liferay.com)

My Requirement
But my requirement is to accept both the things it should may accept both http or without http.so friends kindly give your valuable thoughts for me ..
Subhash Pavuskar
RE: Website Validation(URL)
18 de Fevereiro de 2013 08:35
Resposta

Subhash Pavuskar

Ranking: Regular Member

Mensagens: 234

Data de entrada: 12 de Março de 2012

Mensagens recentes

Hi

If you want to use the regex you already have, but make http and https optional. See following:
var pattern = /((http|https):\/\/)?(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
kabir khan
RE: Website Validation(URL)
18 de Fevereiro de 2013 21:38
Resposta

kabir khan

Ranking: New Member

Mensagens: 21

Data de entrada: 15 de Fevereiro de 2013

Mensagens recentes

Subhash Pavuskar:
Hi

If you want to use the regex you already have, but make http and https optional. See following:
var pattern = /((http|https):\/\/)?(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;




Thank You for your reply.....'


I have achieved validation by using aui validator only ,


So can u explain briefly about to achieve these validation,I have one doubt whether javascript or jquery can be used in the aui form
...

Please help me
Subhash Pavuskar
RE: Website Validation(URL)
18 de Fevereiro de 2013 22:11
Resposta

Subhash Pavuskar

Ranking: Regular Member

Mensagens: 234

Data de entrada: 12 de Março de 2012

Mensagens recentes

Hi kabir khan,

You can have a look at this link !! Click Here
Hope that may help you to understand !!

And Below code is using Jquery validation

 1$.validator.addMethod("cus_url", function(value, element)
 2     {
 3    if(value.substr(0,7) != 'http://')
 4        {
 5        value = 'http://' + value;
 6    }
 7    if(value.substr(value.length-1, 1) != '/')
 8        {
 9        value = value + '/';
10    }
11    return this.optional(element) || /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i.test(value);
12        }, "Not valid url.");
kabir khan
RE: Website Validation(URL)
19 de Fevereiro de 2013 01:17
Resposta

kabir khan

Ranking: New Member

Mensagens: 21

Data de entrada: 15 de Fevereiro de 2013

Mensagens recentes

Subhash Pavuskar:
Hi kabir khan,

You can have a look at this link !! Click Here
Hope that may help you to understand !!

And Below code is using Jquery validation

 1$.validator.addMethod("cus_url", function(value, element)
 2     {
 3    if(value.substr(0,7) != 'http://')
 4        {
 5        value = 'http://' + value;
 6    }
 7    if(value.substr(value.length-1, 1) != '/')
 8        {
 9        value = value + '/';
10    }
11    return this.optional(element) || /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i.test(value);
12        }, "Not valid url.");


Thanks You ,It helps me lot .... Subhash Pavuskar