Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
URL validation
Message
De
26/01/2016 13:15:53
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01630233
Message ID:
01630242
Vues:
74
>>>Hi everybody,
>>>
>>>I have a textbox which will allow to enter a valid URL (https or http). Do you know what code should I use for validation of the user's input?
>>>
>>>Thanks in advance.
>>
>>
Function ValidUrl
>>Lparameters tcUrl
>>Local lcFilter As String, ;
>>   llReturn As Boolean, ;
>>   loRegex As Object
>>If Pcount() > 0 And Vartype(lcMail) = [C]
>>   Text To m.lcFilter Noshow Pretext 15
>>         ^(http(?:s)?\:\/\/[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,6}
>>         (?:\/?|(?:\/[\w\-]+)*)(?:\/?|\/\w+\.[a-zA-Z]{2,4}
>>         (?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$
>>   Endtext
>>   m.loRegex = Createobject([VBScript.RegExp])
>>   m.loRegex.Pattern = m.lcFilter
>>   m.loRegex.IgnoreCase = .T.
>>   m.loRegex.Global = .F.
>>   m.llReturn = m.loRegex.Test(m.tcUrl)
>>   m.loRegex = .Null.
>>   Release m.loRegex
>>Endif
>>Return m.llReturn
>
>Thanks a lot, I'll try that.

You're welcome. The code is a little old, if anything has happened regarding legal URLs in the meantime, you can easily find an updated regex string on Google. Or Bing, to keep Craig happy. :-)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform