Question

Validation

Hi Team

I attempted to perform validation by comparing two fields

for example, I kept a validation on Minimum CTC and maximum CTC(i.e minimum CTC should be greater than maximum CTC) I succeeded to perform this operation.

 

But when I changed the minimum CTC again the validation was not working as expected.

please check my code once

        methods: {

    setValidationConfig: function() {

                // Calls the initialization of validators for the parent view model.

                    this.callParent(arguments);

                // The phoneValidator() validate method is added to the [Phone] column.



                     this.addColumnValidator("UsrMinimumCTC", this.ctcValidation);

                    this.addColumnValidator("UsrMaximumCTC", this.ctcValidation);

                   

                },

                ctcValidation: function() {

                // Variable for storing a validation error message.

                var invalidMessage = "";

                var minimumage = this.get("UsrMinimumCTC");

                var maximumage = this.get("UsrMaximumCTC");

                if (maximumage <= minimumage) {

                    invalidMessage = this.get("Resources.Strings.Agevalidator");

                }

                return {

                // Validation error message.

                    invalidMessage: invalidMessage

                    };

                }

},

 

Hoping for positive Reply.

Regards

manikanta.

 

Like 0

Like

1 comments

Hello manikanta,

Please note that validation is triggered when the object is saved. If the task is to validate data when new record is added to detail you may override "addRecord" detail method and add some custom logic of validation.



Best regards,

Alex

Show all comments