How to validate email,URL and number in Dynamics ax



Description:-

In this Article we will See how to Validate Email Pattern and URL pattern in X++. Here I have Create Job to Validate Email Pattern and URL Pattern to See Enter Email and URL Pattern Using X++.

Validate E-Mail

public void validateEMail()
{
    Boolean valid;
    Boolean xppBool;
    System.Boolean netBool;
    str emailid="UmeshPatel@gmail.com";
    Str MatchEmailPattern = @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"+
        @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."+
        @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"+
        @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";
    System.Text.RegularExpressions.Match myMatch;
    new InteropPermission(InteropKind::ClrInterop).assert();
    myMatch = System.Text.RegularExpressions.Regex::Match(emailid,MatchEmailPattern);
    netBool = myMatch.get_Success();
    xppBool = netBool;
    CodeAccessPermission::revertAssert();
    info(strFmt("%1",xppBool));
}

Validate URL

Static Server boolean validateURL(URL _url)
{
    Boolean valid;
    Boolean xppBool;
    System.Boolean netBool;
    Str matchURLPattern = "^(https?://)"
        + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //user@+ @"(([0-9]{1,3}\.){3}[0-9]{1,3}" 
        //IP- 199.194.52.184+ "|" 
        //allows either IP or domain+ @"([0-9a-z_!~*'()-]+\.)*" 
        //tertiary domain(s)- http://www.+ @"([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." 
        //second level domain+ "[a-z]{2,6})" 
        //first level domain- .com or .museum+ "(:[0-9]{1,4})?" 
        //port number- :80+ ((/?)|" 
        //a slash isn’t required if there is no file name+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
    System.Text.RegularExpressions.Match myMatch;
    new InteropPermission(InteropKind::ClrInterop).assert();
    myMatch = System.Text.RegularExpressions.Regex::Match(_url,matchURLPattern);
    netBool = myMatch.get_Success();
    xppBool = netBool;
    CodeAccessPermission::revertAssert();
    Return xppBool;
}

Validate Number

static void TextBuffer_regularExpression(Args _args)
{
    TextBuffer txt = new TextBuffer();
    str msg = "9999667788";
    ;
    txt.setText(msg);
    txt.regularExpressions(true);//activate regular expr in search
    //Regular expression to validate only digits
    if (txt.find("^[0-9]+$"))
    {
        info("string contains only numbers");
    }
}

Related Posts

Previous
Next Post »

2 comments

comments
January 2, 2021 at 11:28:00 AM GMT+5:30 delete

Track Mobile Number

We can give you the details of mobile number of 22 countries of the world along with the name and home address and location of the owner. The list of countries whose mobile number details are available for you is provided below:
Australia, Bangladesh, Canada, China, Ghana, India, Indonesia, Kenya, Malaysia, Nepal, Norway, Nigeria, Philippines, Poland, Pakistan, Singapore, Suudi Arabia, South Africa, Sri Lanka, United Arab Emiates, United Kingdom, United States

Reply
avatar

Thanks for comments.....