Validating integer field type

Vijaykumar K
Tera Contributor

Hi All, I have a integer field type . In that I need to restrict user to enter only few values like , 10,30,40. If the user try to enter any other values it should throw error .. any one help me with these work around here . Thanks 

1 ACCEPTED SOLUTION

Hi,

Just add one more line as shown below:

 

g_form.showFieldMsg('field_name','Error Message: The entered value is not allowed','error');

g_form.clearValue('field_name'); 

// this will clear value , hope your field is mandatory so user won't be able to submit form with empty field

 

Or use same logic in on submit client script and instead of  clear value use below:

 

g_form.showFieldMsg('field_name','Error Message: The entered value is not allowed','error');

return false;

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

10 REPLIES 10

Hi Anil, yes. It's showing error msg now . But if i try to save it, it's taking values which not called on client script. Is there any changes needed to stop the data base(save)entry apart from value which we called in script ? Ex .If i enter 15 it should not allow me to save.. pls help me with 

Hi Vinay,
Could you please share for which all values you want to show the error messages?

 

 

Thanks. 🙂

Hi,

Just add one more line as shown below:

 

g_form.showFieldMsg('field_name','Error Message: The entered value is not allowed','error');

g_form.clearValue('field_name'); 

// this will clear value , hope your field is mandatory so user won't be able to submit form with empty field

 

Or use same logic in on submit client script and instead of  clear value use below:

 

g_form.showFieldMsg('field_name','Error Message: The entered value is not allowed','error');

return false;

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thanks Anil, working as expected. Thanks a ton

Hi Anil, slight changes needed. There is one more choice field there, So if selection choice is 1, integer should only accept 10, 20,30 and if choice is 2 then only it should accept 40..pls help me to to achieve this request