JSFiddle - React, Tailwind, and code Playground

by Julian

HTML

<form id="comments_form">
        <input type="text" id="name-com" name="name-com" value="" placeholder="Your name" />
      
        <div class="col-lg-8 md-8">
        <input type="email" id="mail-com" name="mail-com" value="" placeholder="Your email address" />

        </div>
<div class="col-lg-8">
        <textarea class="the-new-com" placeholder="Comment"></textarea>
        </div>
        <div class="col-lg-6 md-6">
<button type="submit" id="bt-add-com"  class="btn btn-default">Post</button>
  <div class="bt-cancel-com">Cancel</div>
  
</div>
</form>

JavaScript

$('#bt-add-com').click(function(){
        // on post comment click 
       

            var theCom = $('.the-new-com');
            var theName = $('#name-com');
            var theMail = $('#mail-com');
//verify email
 var testEmail = /^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
 
    if (!testEmail.test(theMail)) alert('fail');{
    
            if( !theCom.val()) alert('please right comment');{
            	
               
             if( !theName.val())
            	alert('please right name');{
}
}
}
            alert ('posted');

});