Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
kabir khan
Website Validation(URL)
18 febbraio 2013 7.18
Risposta

kabir khan

Punteggio: New Member

Messaggi: 21

Data di Iscrizione: 15 febbraio 2013

Messaggi recenti

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 febbraio 2013 8.35
Risposta

Subhash Pavuskar

Punteggio: Regular Member

Messaggi: 234

Data di Iscrizione: 12 marzo 2012

Messaggi recenti

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 febbraio 2013 21.38
Risposta

kabir khan

Punteggio: New Member

Messaggi: 21

Data di Iscrizione: 15 febbraio 2013

Messaggi recenti

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 febbraio 2013 22.11
Risposta

Subhash Pavuskar

Punteggio: Regular Member

Messaggi: 234

Data di Iscrizione: 12 marzo 2012

Messaggi recenti

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 febbraio 2013 1.17
Risposta

kabir khan

Punteggio: New Member

Messaggi: 21

Data di Iscrizione: 15 febbraio 2013

Messaggi recenti

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