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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -