A simple and easy jQuery plugin that automatically opens a dialog pop-up registration form with cool transition effect when the web page loads.
Here I will explain how to open or show jQuery registration form popup window on page load with example or Get jQuery modal popup box to appear on page load. Simple jQuery modal popup window or jQuery modal dialog is used to all kind of form validations and beautiful css styles.
HTML CODE
<!DOCTYPE html> <html> <head> <title>Simple jQuery Popup Window registration form On Page load</title> <link rel="stylesheet" href="main.css"> </head> <body> <div id="boxes"> <div id="dialog" class="window"> <div id="popupfoot"> <a href="#" class="close agree"><img src="button_cancel.png" height="50px" width="100px"></a> </div> <div id="lorem"> <form method="post" name="Registerform" action=""> <p> <select name="salutation" id ="salutation" class="offers" required> <option value="">-Select-</option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Dr">Dr</option> </select> </p> <p><input type = "text" id = "mf_name" class = "mf_name" name="mf_name" value = "" placeholder = "First Name" required /> </p> <p><input type = "text" id = "ml_name" class = "ml_name" name="ml_name" value = "" placeholder = "Last Name" required /></p> <p><input type = "email" id = "mf_email" class = "mf_email" name="mf_email" value = "" placeholder = "Email" required /></p> <p><input type = "text" id = "mf_contact_no" class = "mf_contact_no" name="mf_contact_no" value = "" placeholder = "Mobile number" required /></p> <!-- <p id="lable_align1" class="lable_align1">City</p> --> <p> <select name="City" id ="city_list" class="offers" required> <option value="">-Select City-</option> <option value="1">Abu Dhabi</option> <option value="2">Ajman</option> <option value="3">Dubai</option> <option value="4">Fujairah</option> <option value="5">Sharjah</option> <option value="6">Al Ain</option> <option value="7">Ras Al Khaimah</option> <option value="8">Umm Al Quwain</option> </select> </p> <!-- <p id="lable_align1" class="lable_align1">Where did you hear about us? </p> --> <p><select name="social" id="hear_about" class="hear_about" required> <option value="">Where did you hear about us?</option> <option value="Google">Google</option> <option value="Words of Mouth">Word of Mouth</option> <option value="Facebook">Facebook</option> <option value="Android">Android (Play Store)</option> <option value="Apple">Apple (App Store)</option> <option value="Gulf News">Gulf News</option> </select> </p> <p id="check_align" class="check_align"><lable class="check_lable"><input type="checkbox" id="check" class="check" required ><span class="terms">I agree to terms & conditions</span></lable></p> <p><span id = "terms_and_condition_error" class = "terms_and_condition_error"></span></p> <!--<p id="check_alert" class="check_alert">(Please aggre the term terms and conditions)</p>--> <p><input type="submit" name="query" class = "mail_submit_button mail_submit_button1" value="Submit"></p> </form> </div> </div> <div style="width: 1478px; font-size: 32pt; color:white; height: 602px; display: none; opacity: 0.8;" id="mask"></div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="main.js"></script> </body> </html>
CSS CODE
#mask { position:absolute; left:0; top:0; z-index:9000; background-color:#000; display:none; } #boxes .window { position:absolute; top: 199.5px; top:100px; width:600px; height:auto; display:none; z-index:9999; padding:20px; border-radius: 15px; text-align: center; } #boxes #dialog { width:600px; height:auto; padding:10px; background-color:#E88F0F; font-family: 'Segoe UI Light', sans-serif; font-size: 15pt; } .maintext{ text-align: center; font-family: "Segoe UI", sans-serif; text-decoration: none; } #lorem{ font-family: "Segoe UI", sans-serif; font-size: 12pt; text-align: left; } #popupfoot{ font-family: "Segoe UI", sans-serif; font-size: 16pt; padding: 10px 20px; color:#000000; } #popupfoot a{ text-decoration: none; color:#000000; } .agree:hover{ color:#000000; } .popupoption:hover{ background-color:#D1D1D1; color:#000000; } .popupoption2:hover{ color: red; } /* CSS For Slider */ #slideshow { margin: 140px auto; position: relative; width: 300px; height: 240px; padding: 10px; } #slideshow > div { position: absolute; top: 10px; left: 10px; right: 10px; bottom: 10px; } .bannerinfoji { background-color: #E88F0F; height:auto; width:100%; padding:10px; } /*.popmain1{padding-right:200px !important;}*/ @media screen and (max-width:770px){ .popmain{width:90%; float:left; margin-left:0px;} } @media screen and (max-width:770px){ .popmain1{width:90%; float:left; margin-left:0px; margin-top:-140px;} } @media screen and (max-width:1200px){ #boxes .window { position:absolute; top: 80px !important; left:0px !important; width:90%; height:auto; display:none; z-index:9999; padding:20px; border-radius: 15px; text-align: center; } #boxes #dialog { width:90% !important; left:0px; height:auto; padding:10px; background-color:#E88F0F; font-family: 'Segoe UI Light', sans-serif; font-size: 15pt; } } lable.check_lable {float: left !important;margin: 0;} .mf_name { float: left; height: 40px; margin: 8px 0px 0px 0px; padding: 0 0 0 10px; width: 47%; border:1px solid #000000; background-color:#D2CDD3; color:#000000; } .ml_name { float: left; height: 40px; margin: 8px 0px 0px 0px; padding: 0 0 0 10px; width: 47%; border:1px solid #000000; float:right; background-color:#D2CDD3; color:#000000; } .mf_email { width:98%;float:left;height: 40px;margin: 8px 0px 0px 0px;padding: 0 0 0 10px; border:1px solid #000000; background-color:#D2CDD3; color:#000000;} .mf_contact_no { width:98%;float:left;height:40px;margin:8px 0px 0px 0px;;padding: 0 0 0 10px; border:1px solid #000000; background-color:#D2CDD3; color:#000;} /*.mail_form_content input[type="text"]{ width:100%;float:left;height: 40px;margin: 5px 0 7px;padding: 0 0 0 10px; } .mail_form_content input[type="password"]{ width:100%;float:left;height: 40px;margin: 5px 0 7px;padding: 0 0 0 10px; }*/ .city_list {float: left;height: 40px;margin: 8px 0px 0px 0px;padding: 0 0 0 10px;width: 100%; border:1px solid #000000; border-right: none; background-color:#D2CDD3; color:#000;} .offers{float:left;height:40px;margin:8px 0px 0px 0px;padding:0 0 0 10px;width:100%; border:1px solid #000000; border-right:none; background-color:#D2CDD3; color:#000;} /*.lable_align1 {color: #FFFFFF;font-size: 1.3em;margin: 8px 7px 10px 8px;padding: 0 0 0 10px;width:100%;float: left !important;}*/ .lable_align1 {color: #000000;float: left !important;font-size: 16px;margin: 0 0 0 8px;padding: 0; width: 100%; } .hear_about {float: left;height: 40px;margin: 8px 0px 0px 0px;padding: 0 0 0 10px;width: 100%; border:1px solid #000000; border-right: none; background-color:#D2CDD3; color:#000;} .check_align {float: left;margin: 8px 7px 0px 3px;padding: 2px 0 0px 8px;width:100%;} .terms {color:#000000;margin: 0 0 0 8px;text-align: center;font-size: 16px;} .mf_info {color:#FFF;margin: 0 0 0 8px;text-align: center;font-size: 22px; width:100%;} .mail_submit_button { width:50%;background:#000;color:#FFFFFF;font-size:25px;text-transform:uppercase;padding:5px 10px;border-radius:5px;text-align:center;float:right;margin:0;cursor:pointer; } input:focus { border:2px solid #F0A91A; }
JQUERY CODE
$(document).ready(function() { var id = '#dialog'; //Get the screen height and width var maskHeight = $(document).height(); var maskWidth = $(window).width(); //Set heigth and width to mask to fill up the whole screen $('#mask').css({'width':maskWidth,'height':maskHeight}); //transition effect $('#mask').fadeIn(500); $('#mask').fadeTo("slow",0.9); //Get the window height and width var winH = $(window).height(); var winW = $(window).width(); //Set the popup window to center $(id).css('top', winH/2-$(id).height()/2); $(id).css('left', winW/2-$(id).width()/2); //transition effect $(id).fadeIn(2000); //if close button is clicked $('.window .close').click(function (e) { //Cancel the link behavior e.preventDefault(); $('#mask').hide(); $('.window').hide(); }); //if mask is clicked $('#mask').click(function () { $(this).hide(); $('.window').hide(); }); });
I hope you like this Article. Share with your friends.
My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.