Last active
May 30, 2018 09:17
-
-
Save suebphatt/c4c7885d28815bdb66106826cfca73a7 to your computer and use it in GitHub Desktop.
USERNAME INPUT FIELD JS - english only / no space / allows special chat only _
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- username input | |
$("#username").on('keyup change', function(event){ | |
var sanitized = $(this).val().toString().replace(/[^\u0000-\u007F]+/, '').replace(/ /g, '').replace(/[^\w\s]/gi, ''); | |
$(this).val(sanitized); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment