Validate only numbers in a text field (I would like to validate it using javascript code)

If you are referring to a text user input, then you’ll need to change a type of your input from Text to Number in the settings: