0

I want to add JavaScript validation to my input.

The Form is generated dynamically as per the information from database. I have field called regex where i store the expression to be applied to that field So I fetch the regex but how to apply it to the form ? I want to allow only comma separated numbers how to do this:

This is my generated HTML

<tr>
    <td>Codec</td>
    <td><input type="text" name="Codec" value="8"/></td>
</tr>

This is the regex i want to apply to my input : ^[0-9 _ ,]*$

What should be my java-script to check the input?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rajan
  • 2,427
  • 10
  • 51
  • 111

1 Answers1

3

You can validate the input on the html input tag. Just use pattern="[0-9 _,]*"

ItzikEdar
  • 207
  • 1
  • 2
  • 9