Validation of string field!!

Snow Guest
Tera Contributor

I have two fields one is height and another is weight.

 

Height should only accept two numbers i.e one number before decimal and another is after decimal if not it should show some error. 

 

Wight should only accept three numbers i.e two numbers before decimal and one number after decimal.

 

Note: I have taken integer as a field type!!

1 ACCEPTED SOLUTION

Community Alums
Not applicable
3 REPLIES 3

Community Alums
Not applicable

Hi @Snow Guest ,

Here is sample script.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var sdVal=g_form.getValue('short_description');
var splitVal=sdVal.split('.');
alert("First = "+splitVal[0]+"second = "+splitVal[1]);
var len=splitVal[1].length;
alert(len);
if(len>3){
alert('wrong decimal value');
}
else{
alert('correct decimal value');
}

}

 

Note - Make changes accordingly as per need.

 

Community Alums
Not applicable

Hi @Snow Guest ,

 

May i know how to calculate integer field length in on change client script:

 

i did like var abc= g_form.getvalue('field name');

len= abc.length;

 

but len not taking actual length its not getting as per requirement weight clint script.PNG