I want to implement the functionality so that the input box (type search) does not let the user enter any letters/alphabets and only allows numbers(in text type)
hi,
here u go:
https://www.outsystems.com/forums/discussion/78790/allow-user-only-put-numbers-on-input-widget/
Hi @Syeda Aliha Naeem ,
Please check the oml file.
Hope this will help you
Hi @Syeda Aliha Naeem ,I have attached the OML, Hope this will help.Asad
I tried this and success!!
Thanks @Asad Sheikh
Hi Syeda Aliha Naeem ,I have attached the oml for your issue , please look into it.
@Syeda Aliha Naeem Use this js to restrict Alphabets and to enter only numbers in input field.
var
output=document.activeElement.id
document.getElementById(output).value=document.getElementById(output).value.replace(/[^0-9#@_\-/()./s]/gi,"");
use this js in oninput of the input field
Hi,
Try to use input mask forge component or regex
Regards
Shradha
Hi,As praveen Suggested use JS to prevent the alphabets, in addition to that restrict a default key "e" to remove that add JS var e = window.event || e; var key = e.keyCode; if (key == 69) { e.preventDefault(); return false; }
can you check this links
https://www.outsystems.com/forums/discussion/86480/how-to-restrict-text-in-text-input-field-and-allow-user-to-enter-only-numbers/
Validation with Regular Expression
If you want to be even more restrictive (e.g., allowing only digits), you can use an event to validate the user's input. A common method is to use the OnChange or OnInput event to trigger an action.Add a Client Action to the input widget and use a regular expression to validate the input: if (!/^\d*$/.test($parameters.InputValue)) { $parameters.InputValue = $parameters.InputValue.replace(/\D/g, '');}This removes any non-numeric characters that the user has entered.