Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Piccolo esempio di dialog modale</title>
- <style type="text/css">
- /*CODICE CSS PER LA DIALOG E SFONDO*/
- .dialog{
- margin:auto;
- width:500px;
- height:140px;
- border:1px solid #CCC;
- padding:10px;
- left:0px;
- top:0px;
- bottom:0px;
- right:0px;
- position:fixed;
- background-color:#FFF;
- display:none;
- z-index:1000;
- border-radius:3px;
- }
- .overlay{
- position:fixed;
- width:100%;
- height:100%;
- background-color:#000;
- background-color:rgba(0, 0, 0, 0.5);
- z-index:999;
- left:0px;
- top:0px;
- display:none;
- }
- //CODICE CSS PER IL RESTO DELLA PAGINA
- .text{
- font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
- font-size:14px;
- color:#333;
- }
- .big{
- font-size:24px;
- }
- .dialog-newsletter-mail{
- width:400px;
- float:right;
- }
- .dialog-newsletter-button{
- width:100px;
- height:30px;
- float:right;
- cursor:pointer;
- border:1px solid #CCC;
- background-color:#EEE;
- border-radius:3px;
- text-align:center;
- }
- .dialog-newsletter-button:hover{
- background-color:#CCC;
- }
- </style>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
- <script type="text/javascript">
- function validateEmail(email) {
- if ( email == "" ){
- return false;
- }
- var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
- return re.test(email);
- }
- function showDialog(){
- //MOSTRA LA DIALOG
- $("#dialog-newsletter").fadeIn(250);
- $("#overlay-newsletter").fadeIn(250);
- return true;
- }
- function activateNewsletter(){
- var mail = $("#dialog-newsletter-mail").val();
- //PRIMA DI FARE QUALSIASI COSA VALIDA LA MAIL
- if ( validateEmail(mail) == false ){
- alert("La mail inserita non è valida!");
- return false;
- }
- //FAI L'ISCRIZIONE CON LA MAIL INSERITA
- //CHIUDI LA DIALOG
- $("#dialog-newsletter").fadeOut(250);
- $("#overlay-newsletter"). fadeOut(250);
- return true;
- }
- //MOSTRI LA DIALOG AL CARICAMENTO DELLA PAGINA
- $(function(){
- showDialog();
- });
- </script>
- </head>
- <body>
- <div class="dialog" id="dialog-newsletter">
- <!--
- IL RELATIVO CONTENUTO E STILE TE LO GESTIRAI POI IN BASE ALLE TUE ESIGENZE...
- <!-->
- <span class="text big">Iscriviti alla newsletter</span>
- <br /><br />
- <span class="text">Mail:</span> <input required type="email" id="dialog-newsletter-mail" placeholder="inserisci qui la tua mail" class="text dialog-newsletter-mail" />
- <br /><br /><br />
- <button onClick="activateNewsletter();" class="dialog-newsletter-button text">OK</button>
- </div>
- <div class="overlay" id="overlay-newsletter"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment