How to create a number type field as a variable in a catalog item?

Kata SriLakshmi
Tera Contributor

I created a variable and gave type as single line text. In this i want this variable field to be restricted to only numeric characters.

2 ACCEPTED SOLUTIONS

manjusha_
Kilo Sage

@Kata SriLakshmi 

 

You can use single line text type to create a number type field .

There is no such a specific type for number field 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact

Thanks,

Manjusha Bnagale

View solution in original post

@Kata SriLakshmi 

 

I wanted to tell you to create a variable of type single line text which you already created

Check below code to allow user to enter numeric value only for your single line  field 

 

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

 

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

  return;

  }

  var regexp = /^[+]?\d*$/;

 

  if(!regexp.test(newValue)){

 

  alert('Please enter numeric value');

 

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

 

  }

}

 

in addition I defined "variable attributes   max_length=3" to accept up to 3 digits

 

 

Refer below source-

Regular Expression Library

 

You can also Refer:

RegEx in condition builder

 

Thanks,

Manjusha Bangale

View solution in original post

4 REPLIES 4

manjusha_
Kilo Sage

@Kata SriLakshmi 

 

You can use single line text type to create a number type field .

There is no such a specific type for number field 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact

Thanks,

Manjusha Bnagale

How to create number type with single line text field

 

@Kata SriLakshmi 

 

I wanted to tell you to create a variable of type single line text which you already created

Check below code to allow user to enter numeric value only for your single line  field 

 

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

 

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

  return;

  }

  var regexp = /^[+]?\d*$/;

 

  if(!regexp.test(newValue)){

 

  alert('Please enter numeric value');

 

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

 

  }

}

 

in addition I defined "variable attributes   max_length=3" to accept up to 3 digits

 

 

Refer below source-

Regular Expression Library

 

You can also Refer:

RegEx in condition builder

 

Thanks,

Manjusha Bangale

Kata SriLakshmi
Tera Contributor

Thanks Manjusha