Jump to content

Allow only numbers in a field


Recommended Posts

I have a table field AGE set as an integer.  I need the form to disallow alpha characters in that field when exiting that field.  Cant get ti to work.  I still have submissions allowing "approx. 50" and I need to limit them to discrete numbers only.

I added this script in footer, which helps, but its only on submit.  Isnt the fact that the field type is INTEGER mean it wont accept letters by default?

<script>function isNumberKey(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true;}document.getElementById('@field:Age').onkeypress =isNumberKey;</script>

Link to comment
Share on other sites

On 4/22/2017 at 9:53 PM, roattw said:

I have a table field AGE set as an integer.  I need the form to disallow alpha characters in that field when exiting that field.  Cant get ti to work.  I still have submissions allowing "approx. 50" and I need to limit them to discrete numbers only.

I added this script in footer, which helps, but its only on submit.  Isnt the fact that the field type is INTEGER mean it wont accept letters by default?

<script>function isNumberKey(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true;}document.getElementById('@field:Age').onkeypress =isNumberKey;</script>

You need to use this script in the html block. Add html block, place it below all the fields, hit Source tab and insert your script. Also I would recommend using complete syntax InsertRecordAge instead of '@field:Age'.

Integer datatype doesn't allow entering characters only on the table level in datasheet view.

Hope that helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...