How to restrict value in a single field

alona3
Tera Contributor

how to restrict value in a single field
It will only accept a number range between 6000000 – 6999999 (8 numeric char).
If not meet, message will appear:
"This task is only relevant for Customers with a number range between 6000000 – 6999999"

1 ACCEPTED SOLUTION

Prashant Ahire
Kilo Sage

@alona3 

Did this helped you?

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful.
Thanks

View solution in original post

7 REPLIES 7

Prashant Ahire
Kilo Sage

Hello @alona3 
Please use this client script for the field 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    // Get the current field value
    var fieldValue = g_form.getValue('field_name'); // Replace 'your_field_name' with the actual field name

    // Define the valid number range
    var minNumber = 6000000;
    var maxNumber = 6999999;

    // Check if the field value is a numeric value within the valid range
    if (isNaN(fieldValue) || fieldValue < minNumber || fieldValue > maxNumber) {
        // Display an error message
        alert('Error! This task is only relevant for Customers with a number range between 6000000 – 6999999');

        // Set the field value to an empty string or another default value if needed
        g_form.setValue('field_name', ''); // Replace 'your_field_name' with the actual field name
    }
    //Type appropriate comment here, and begin script below

}

 

 

Please check and Mark Correct and Helpful if it really helps you.
Regards,
Prashant Ahire

Thank you for quick response.

Is this onChange?

Prashant Ahire
Kilo Sage

Yes this is onChange

Hello,

thank you so much it works.

Additional question can i add link in the error message?

Message: 

This task is only relevant for Customers with a number range between 6000000 – 6999999. 

All other customers can be reactivated using the following instruction: LINK

In case of any problems, please do not hesitate to contact CIT