A condition preventing registration if the field does not contain at least a certain number of characters ?

Hello everybody,

How to set a field number phone that dose not register if it doesn't contain at least 14 characters ? 

I appreciate any help Slight smile

Parents
  • Hello ,

    You can do it through code.

    First, locate the record.js file for your specific module. You’ll typically find it at the following path:

    custom/modules/yourModule/clients/base/views/record/record.js


    ({
    	extendsFrom: 'RecordView',
    
    	initialize: function (options) {
    		this._super('initialize', [options]);
    		this.context.on('button:save_button:click', this._save_desc, this);
    	},
    	
    	_save_desc: function (model) {
            let phone = this.model.get('phone_mobile');
    
            // Convert the number to a string
            let phoneString = phone.toString();
            
            // Get the length of the string
            let length = phoneString.length;
            
            if (length < 14) {
                app.alert.show('error', {
                    level: 'error',
                    messages: 'The length was less than 14 digits',
                    autoClose: false
                });
            } else {
                // do something
            }
        },
    })


    After adding this code do repair and rebuild to make it action.

    Note:- This code works when you save the record.

    From this you can acheive what you want.


    Thank you...

Reply
  • Hello ,

    You can do it through code.

    First, locate the record.js file for your specific module. You’ll typically find it at the following path:

    custom/modules/yourModule/clients/base/views/record/record.js


    ({
    	extendsFrom: 'RecordView',
    
    	initialize: function (options) {
    		this._super('initialize', [options]);
    		this.context.on('button:save_button:click', this._save_desc, this);
    	},
    	
    	_save_desc: function (model) {
            let phone = this.model.get('phone_mobile');
    
            // Convert the number to a string
            let phoneString = phone.toString();
            
            // Get the length of the string
            let length = phoneString.length;
            
            if (length < 14) {
                app.alert.show('error', {
                    level: 'error',
                    messages: 'The length was less than 14 digits',
                    autoClose: false
                });
            } else {
                // do something
            }
        },
    })


    After adding this code do repair and rebuild to make it action.

    Note:- This code works when you save the record.

    From this you can acheive what you want.


    Thank you...

Children
No Data