- Home
- Forum
- Xamarin.Forms
- RegEx for URL validation
RegEx for URL validation
Hi,
I'd like to use the masked edit for basic URL validation but I'm unsure how to go about doing so with the limited mask characters that the SfMaskedEdit allows.
https://help.syncfusion.com/xamarin-ios/sfmaskededit/masktype#regex-mask-characters
Could you please assist?
Thank you
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
RS
Ramya Soundar Rajan
Syncfusion Team
June 12, 2020 02:10 PM UTC
Hi Malcolm,
Greetings from Syncfusion.
We have prepared a simple sample for the simple Regex mask. Please refer the below code snippet.
|
<maskededit:SfMaskedEdit x:Name="maskedEdit" MaskType="RegEx" Mask="(https?:\/\/)?([\w\-]+\.{1}([a-zA-Z]{2,63})([\/\w-]*)*\/?\??([^\n\r]*)?([^\n\r]*)"/> |
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/MaskedEditDemo-120961254
Output:
We would like to let you know that the reported query it’s general query. Based on your requirement to validate the url, you can give Regex to set value for the Mask property. we have provided support for limited Mask. Please refer the following user guide link for more information about regular expression that supported by MaskedEdit.
Regards,
Ramya S
Marked as answer
JR
Jassim Rahma
November 19, 2021 02:51 PM UTC
Hi
I tried your regex and it shows invalid URL because of the dot
Please see the attached sample
Attachment: GSMastedEdit_8119eef.zip
VR
Vignesh Ramesh
Syncfusion Team
November 22, 2021 12:57 PM UTC
Hi Jassim Rahma,
We have checked your query and screenshot. We would like to inform you that, we must provide any letters or hyphens (-) before the dot as per the previous Mask, then only it is the valid Url. Otherwise, it is invalid. In your screenshot, you didn’t provide any letters or hyphens before the dot. So only it returns as invalid. Please refer to the screenshot below
(https?:\/\/)?([\w\-]+\.{1}([a-zA-Z]{2,63})([\/\w-]*)*\/?\??([^\r]*)?([^\r]*)
The [\w\-]+ denotes, you must type any number of letters or hyphens.
Also, as we have mentioned in our previous update, the regular expression is a general concept of C#, and our MaskedEdit supports it to specify the rules for accepting inputs. So, you have to create a regular expression based on your requirement.
Please find the below guidelines for generating the regular expression mask
Regards,
Vignesh Ramesh.
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
- Marked answer
-
MV Malcolm van Staden
- Jun 11, 2020 08:25 AM UTC
- Nov 22, 2021 12:57 PM UTC