javascript - check if input ends with specific character -
i have basic input field:
<input type="text" name="one" />
how can make sure user ends input value specific character, example comma (,) before running server-side code?
example:
"hello world" (invalid)
"hello world," (valid)
why don't use html5 pattern validation? it's easy , no javascript maintain.
demo snippet:
<form> <input type="text" name="one" pattern=".*,$" /> <input type="submit" value="submit" /> </form>
Comments
Post a Comment