I want to check input username for correct input.
First Problem: i have many users in east europe, so special characters must be inside. Some Users choose email as username, some (it is a database for dogs) choose their kennelname which can also contain an apostrophe.
I am using Just Validate / javascript for first checking.
I tried
const validation = new JustValidate('#form');
validation
.addField('#username', [
{
rule: 'minLength',
value: 3,
errorMessage: '<?=$translation_form_too_short?>',
},
{
rule: 'maxLength',
value: 30,
errorMessage: '<?=$translation_form_too_long?>',
},
{
rule: 'customRegexp',
value: /[a-zA-ZÁáÀàÂâÃãÄäĂăĀāÅåĄąÆæÉéÈèÊêËëĚěĒēĖėĘęÍíÌìÎîÏïĪīĮįIıÓóÒòÔôÕõÖöŐőØøÚúÙùÛûÜüŰűŪūůYÝýĆćČčçĎďĐđĐðĢģĞğĶķŁłĻļŃńÑñŇňŅņŊŋŘřŚśŠšŞşßŤťŦŧÞþŢţŻżŹźŽž[email protected]]+/gu,
errorMessage: '<?=$translation_register_username_condition?>!',
},
too long / short works fine but regex don´t.
Same regex with html pattern, also not working.
with
document.getElementById("username").onkeypress = function(e) {
var chr = String.fromCharCode(e.which);
if (">)(<[#*+;/"".indexOf(chr) >= 0)
return false;
};
i can’t insert f.e. É (on german keyboard).
Allowed should be all latin letters, digits, space, minus, apostrophe, dot and @.
Forbidden should be <>;_#*+!Ӥ$%&/()=?{[]}