JSFiddle - React, Tailwind, and code Playground

by Gregory Nikitas

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<div class="modal fade" id="nuovoUtente" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Aggiungi utente</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="main">
                <form id="formUtenti" action="#">
                <div class="form-group">
                    <label for="exampleInputEmail1">Nome</label>
                    <input type="text" class="form-control" id="aggNomeUtente" placeholder="Inserisci il nome">
                </div>
                <div class="form-group">
                    <label for="exampleInputEmail1">Cognome</label>
                    <input type="text" class="form-control" id="aggCognomeUtente" placeholder="Inserisci il cognome">
                </div>
                <div class="form-group">
                    <label for="exampleInputEmail1">Funzione</label>
                    <textarea class="form-control" id="aggFunzioneUtente" rows="3"></textarea>
                </div>
                <div class="form-group">
                    <label for="exampleInputEmail1">E-Mail</label>
                    <input type="email" class="form-control" id="aggMailUtente" placeholder="Inserisci la Mail">
                    <small id="emailHelp" class="form-text text-muted"><i class="fas fa-exclamation-triangle warningTriangolo"></i> Credenziale di accesso</small>
                </div>
                <div class="form-group">
                    <label for="exampleInputEmail1">Password</label>
           ...

JavaScript

//This will show the necessary section the next time a link is clicked on
$('#nuovoUtente').on('show.bs.modal', function () {
   $('#main').show(); 
	 $('#errmsg').hide();
});
//This will toggle in the error message, use the contents of this in your "fail" function
$(document).on("click", "#aggNuovoUtente", function(){
	$('#errmsg, #main').toggle()
});
//This will just bring up the modal if you click on the screen (for this example)
$(document).on("click", function(){
	$("#nuovoUtente").modal("show");
});
//This shows the modal on load
$("#nuovoUtente").modal("show");