I've spent a lot of time to search this feature.
when i have to create a web form or a registration portlet in multistep in liferay.
so we only use a single jsp to create the form and show and hide the fields using java script.
in your view.jsp put this code :)
 
and in your main.js file put this...
 
and in your main.css put this file :)
 
for demo :- Live Demo
when i have to create a web form or a registration portlet in multistep in liferay.
so we only use a single jsp to create the form and show and hide the fields using java script.
in your view.jsp put this code :)
| <html><head><title>Multistep Registration Form</title><!--including css file here---><linkrel="stylesheet"type="text/css"href="/css/main.css"/><!--including Javascript file here---><scripttype="text/javascript"src="/js/main.js"></script></head><body><divclass="content"<!-- multistep form --><divclass="main"><formclass="regform"action=""method="get"> <!-- progressbar --> <ulid="progressbar"> <liid="active1">Create Account</li> <liid="active2">Educational Profiles</li> <liid="active3">Personal Details</li> </ul> <!-- fieldsets --> <fieldsetid="first"> <h2class="title">Create your account</h2> <pclass="subtitle">Step 1</p> <inputtype="text"name="email"placeholder="Email"/><br/> <inputtype="password"name="pass"placeholder="Password"/><br/> <inputtype="password"name="cpass"placeholder="Confirm Password"/><br/> <inputtype="button"id="next_btn1"value="Next"onclick="next_step1()"/> </fieldset> <fieldsetid="second"> <h2class="title">Educational Profiles</h2> <pclass="subtitle">Step 2</p> <selectclass="options"> <option>--Select Education--</option> <option>Post Graduate</option> <option>Graduate</option> <option>HSC</option> <option>SSC</option> </select><br/> <inputtype="text"name="marks"placeholder="Marks Obtained"/><br/> <inputtype="text"name="pyear"placeholder="Passing Year"/><br/> <inputtype="text"name="univ"placeholder="University"/><br/> <inputtype="button"id="pre_btn1"value="Previous"onclick="prev_step1()"/> <inputtype="button"name="next"id="next_btn2"value="Next"onclick="next_step2()"/> </fieldset> <fieldsetid="third"> <h2class="title">Personal Details</h2> <pclass="subtitle">Step 3</p> <inputtype="text"name="fname"placeholder="First Name"/><br/> <inputtype="text"name="lname"placeholder="Last Name"/><br/> <inputtype="text"name="cont"placeholder="Contact"/><br/> <label>Gender</label><br/> <inputname="gender"type="radio"/>Male<br/> <inputname="gender"type="radio"/>Female<br/> <textareaname="address"placeholder="Address"></textarea><br/> <inputtype="button"id="pre_btn2"value="Previous"onclick="prev_step2()"/> <inputtype="submit"class="submit_btn"value="Submit"/> </fieldset></form></div></div></body></html> | 
and in your main.js file put this...
| /*------------validation function-----------------*/varcount=0; // to count blank fieldsfunctionvalidation(event){ //fetching radio button by name varradio_check = document.getElementsByName('gender'); //fetching all inputs with same class name text_field and an html tag textarea varinput_field = document.getElementsByClassName('text_field'); vartext_area = document.getElementsByTagName('textarea'); //validating radio button if(radio_check[0].checked== false&& radio_check[1].checked== false){ vary = 0; } else{ vary = 1; } //for loop to count blank inputs for(vari=input_field.length;i>count;i--){ if(input_field[i-1].value==''|| text_area.value=='') { count = count + 1; } else{ count = 0; } } //Notifying validation if(count!=0||y==0){ alert("*All Fields are mandatory*"); event.preventDefault(); } else{ returntrue; }}/*---------------------------------------------------------*///Function that executes on click of first next buttonfunctionnext_step1(){ document.getElementById("first").style.display="none"; document.getElementById("second").style.display="block"; document.getElementById("active2").style.color="red"; }//Function that executes on click of first previous buttonfunctionprev_step1(){ document.getElementById("first").style.display="block"; document.getElementById("second").style.display="none"; document.getElementById("active1").style.color="red"; document.getElementById("active2").style.color="gray"; }//Function that executes on click of second next buttonfunctionnext_step2(){ document.getElementById("second").style.display="none"; document.getElementById("third").style.display="block"; document.getElementById("active3").style.color="red"; }//Function that executes on click of second previous button functionprev_step2(){ document.getElementById("third").style.display="none"; document.getElementById("second").style.display="block"; document.getElementById("active2").style.color="red"; document.getElementById("active3").style.color="gray"; } | 
and in your main.css put this file :)
| .content{ width:960px; margin:20pxauto; }.main{ float:left; width: 650px; margin-top:80px; }#progressbar{ margin:0; padding:0; font-size:18px; }#active1{ color:red; }fieldset{ display:none; width: 350px; padding:20px; margin-top:50px; margin-left: 85px; border-radius:5px; box-shadow: 3px3px25px1pxgray; }#first{ display:block; width: 350px; padding:20px; margin-top:50px; border-radius:5px; margin-left: 85px; box-shadow: 3px3px25px1pxgray; }input[type=text],input[type=password],select{ width:100%; margin:10px0; height:40px; padding:5px; border: 3pxsolidrgb(236, 176, 220); border-radius: 4px; }textarea{ width:100%; margin:10px0; height:70px; padding:5px; border: 3pxsolidrgb(236, 176, 220); border-radius: 4px; }input[type=submit],input[type=button]{ width: 120px; margin:15px25px; padding: 5px; height: 40px; background-color: sienna; border: none; border-radius: 4px; color: white; font-family: 'Droid Serif', serif; }h2,p{ text-align:center; font-family: 'Droid Serif', serif; }li{ margin-right:52px; display:inline; color:#c1c5cc; font-family: 'Droid Serif', serif; } | 
for demo :- Live Demo
 
No comments:
Post a Comment