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); | |
}); |
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
// -- number only 2 | |
$(".only-number").on('keyup change', function(){ | |
// Remove invalid characters | |
var sanitized = $(this).val().toString().replace(/[^0-9]/g, ''); | |
// Update value | |
$(this).val(sanitized); | |
}); |
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
// -- english only | |
$(".english-only").on('keyup change', function(event){ | |
var sanitized = $(this).val().toString().replace(/[^\u0000-\u007F]+/, ''); | |
$(this).val(sanitized); | |
}); |