Skip to content

Instantly share code, notes, and snippets.

@ricardobrg
Created June 6, 2018 03:06
Show Gist options
  • Save ricardobrg/51b3ed8f2761a45bf0b787235966ee86 to your computer and use it in GitHub Desktop.
Save ricardobrg/51b3ed8f2761a45bf0b787235966ee86 to your computer and use it in GitHub Desktop.
input number maxlength with javascript oninput
<input type="number" step="1" min="1" max="999" maxlength="3" name="number" inputmode="numeric" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment