Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Do not allow user to enter non-number characters

Avatar

Level 8

Hello

For some reason the have used the TEXT FIELD object for numeric data input field.

Actually, user has to always enter numeric data ONLY.

No decimals, no commas, no alphabetical characters allowed except numbers.

(Syststem should not allow user enter non-allowed data at all....i mean to say, when we achive by using Numeric field/object.... or If user trying to enter any non-allowed data i hv to throw an error and CLEAR the field immediately)

Pls. let me know How to get my requirement? Do i need to use JavaScript or Pattern or Validation Pattern in object pallette or ALL 3?

I am newbie, pls. provide me the code (if JavaScript)

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can use a small script with a regular expression in the change Event of yout textfield, to check the current input and remove everyting that is not a digit.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

You can use a small script with a regular expression in the change Event of yout textfield, to check the current input and remove everyting that is not a digit.

Avatar

Level 8

Thank you, perfect, simple, awesome.