Update the validation of the fields on ‘Add New Address’ popup

The default validation of the fields on the ‘Add New Address’ popup form can be updated as shown below.

  • To change the name of the fields, we can directly update it in template file of the corresponding popup.
  • To update the validation of the fields, like to make the fields optional or mandatory and to change the validation message, we can extend the validation function as shown below.
 _.extend(AddressModel.prototype, {
                    validation: _.extend(AddressModel.prototype.validation, {
                        state: { required: true, fn: Utils.validateState, msg: Utils.translate('Province is required') },
                        zip: { fn: Utils.validateZipCode, msg: Utils.translate('Postal Code is required') }
                    })
                })

The validation function on source code is shown below

Leave a comment

Your email address will not be published. Required fields are marked *