How to define a range specification in client scripts

Mi1
Tera Contributor

Hi,

I don't want to let you enter certain numbers.

Example) Allow the input of numbers other than 1-10. 

Can I define a range specification in client processing?

Regards,

1 ACCEPTED SOLUTION

so you want to allow numbers from 151? In that case you dont need regex. Regex is used to validate formats.

You can use client script for this

var x = g_form.getValue('fieldname');

if ( x >100 || x <= 150)

{

alert("Numbers cannot be between 100 and 150);

}

Regards
Harish

View solution in original post

8 REPLIES 8

OlaN
Giga Sage
Giga Sage

Hi,

You can define a regular expression that allows for entering specific patterns.

For example, this will allow for entering 2 or more digits in a string.

var regex = /^[\d]{2,}$/;
var testString = '234';

if (test1.match(regex))
    g_form.addInfoMessage('success on ' + testString);
else
    g_form.addErrorMessage(testString + ' does not match the pattern');

Mi1
Tera Contributor

Hi,

Thank you.

What does this phrase mean? How can I write code when I don't want to let a number between "100-150" be entered?

Regards,

Regular expression is used to validate what you should enter.

Can you explain what you mean by "100-150 not allowed"?

Are numbers 1-99 allowed? Are numbers 151 and higher allowed?

Mi1
Tera Contributor

Hi,

Thank you.

As you say, 1-99 is a requirement that permission be granted, and the number of section 151 is also permitted.

Regards,