How to validate number in ax 2012

Description:-

In this article we will see about how to validate number based on some expression or else if we want to validate some particular expression like number should be First 5 char, after 5 number after 3 char.

Here is some validation expression so you can use for validate your string value or else in any other object value for some specific Fields.

public boolean validateWrite()
{
    boolean ret;
    #define.alphabets('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    #define.numbers('0123456789')
    #define.10(10)
    #define.12(12)

    ret = super();

    if (ret && (strkeep(substr(this.RegistrationNumber, 1, 4), #alphabets) != substr(this.RegistrationNumber, 1, 4)) ||
        (strkeep(substr(this.RegistrationNumber, 5, 5), #numbers)   != substr(this.RegistrationNumber, 5, 5)) ||
        (strlen(this.RegistrationNumber)                            != #10)                                   ||
        (strkeep(substr(this.RegistrationNumber, 10, 1), #alphabets)!= substr(this.RegistrationNumber, 10, 1)))
    {
        ret = ret && checkFailed("@GLS5456");
    }
}

Related Posts

Previous
Next Post »

Thanks for comments.....