Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to Set Integer Validation for multiple Variables at a time.

VikramM1
Tera Contributor

Hi All,

 

I have created record producer mapping custom table fields. I have some integer fields in custom table. But, in Record producer variable type there is no integer option. Since, i selected single line text. 

 

Can someone help me how to set integer validation for multiple variables at a time.

 

Thanks,

1 ACCEPTED SOLUTION

@VikramM1 

You can modify the code something like below:

 

function onSubmit() {
   var variableNames = ['variable_name1', 'variable_name2', 'variable_name3'];
    for (var i = 0; i < variableNames.length; i++) {
        var inputValue = g_form.getValue(variableNames[i]);
        var intValue = parseInt(inputValue);
        
        if (isNaN(intValue)) {
            alert('Please enter a valid integer value for ' + variableNames[i] + '.');
            return false; // Prevent submission
        }
    }
    
    // Proceed with submission
    return true;
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

View solution in original post

5 REPLIES 5

Sumanth16
Mega Patron

Hi @VikramM1 ,

 

You can select number field (or) create below validations on single text field:

 

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

          return;

    }

 

    //Type appropriate comment here, and begin script below

    var pattern=/[^\d]/g;

var b=pattern.test(newValue);

if(b=='true')

{

g_form.hideFieldMsg('numeric'); //name of the field you are using

g_form.addErrorMessage('numeric',"Please Enter numerical value only","error");

g_form.setValue('numeric','');

}

}