JSFiddle - React, Tailwind, and code Playground

HTML

<input id="firstname" type="text" value="dsa342%#$#@">

JavaScript

var alphanumers = /^[a-zA-Z0-9]+$/;
if(!alphanumers.test($("#firstname").val())){
    alert("Nickname can have only alphabets and numbers.");
}