123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- var current_fs, next_fs, previous_fs;
- var left, opacity, scale;
- var animating;
- $(".next").click(function(){
- if( !validate() ){
- return false;
- }
- if(animating) return false;
- animating = true;
-
- current_fs = $(this).parent();
- next_fs = $(this).parent().next();
-
-
- $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
-
-
- next_fs.show();
-
- current_fs.animate({opacity: 0}, {
- step: function(now, mx) {
-
-
- scale = 1 - (1 - now) * 0.2;
-
- left = (now * 50)+"%";
-
- opacity = 1 - now;
- current_fs.css({
- 'transform': 'scale('+scale+')',
- 'position': 'absolute'
- });
- next_fs.css({'left': left, 'opacity': opacity});
- },
- duration: 800,
- complete: function(){
- current_fs.hide();
- animating = false;
- },
-
- easing: 'easeInOutBack'
- });
- });
- $(".previous").click(function(){
- if(animating) return false;
- animating = true;
-
- current_fs = $(this).parent();
- previous_fs = $(this).parent().prev();
-
-
- $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
-
-
- previous_fs.show();
-
- current_fs.animate({opacity: 0}, {
- step: function(now, mx) {
-
-
- scale = 0.8 + (1 - now) * 0.2;
-
- left = ((1-now) * 50)+"%";
-
- opacity = 1 - now;
- current_fs.css({'left': left});
- previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
- },
- duration: 800,
- complete: function(){
- current_fs.hide();
- animating = false;
- },
-
- easing: 'easeInOutBack'
- });
- });
- $("input[name=submit]").click(function(){
-
- showThankyou();
- })
- function showThankyou() {
- $('#overlay').show();
- }
- $('.btn-exit').click(function() {
- document.location = 'https://hhh.com.tw/'
- })
- function show_input_text(checkbox_id, input_id) {
- var checkBox = document.getElementById(checkbox_id);
- var inp = document.getElementById(input_id);
- if (checkBox.checked == true){
- inp.style.display = "block";
- } else {
- inp.style.display = "none";
- }
- }
- function validate() {
- function q2_validate() {
- let phoneno = /^\d{10}$/;
- if( $('input[name="q2"]:visible').val() !== undefined && $('input[name="q2"]:visible').val().length <= 0) {
- $('input[name="q2"]:visible').addClass('error');
- if( !$('.error-text').length )
- $('input.error').after('<p class="error-text">請輸入正確手機號碼</p>');
- return false;
- } else if($('input[name="q2"]:visible').val() !== undefined && !phoneno.test($('input[name="q2"]:visible').val())){
- $('input[name="q2"]:visible').addClass('error');
- if( !$('.error-text').length )
- $('input.error').after('<p class="error-text">請輸入正確手機號碼</p>');
- return false;
- }else {
- $('input[name="q2"]:visible').removeClass('error');
- $('.error-text').remove();
- return true;
- }
- }
- function q3_validate() {
- if( $('input[name="q3"]:visible').val() !== undefined && $('input[name="q3"]:visible').val().length <= 0) {
- $('input[name="q3"]:visible').addClass('error');
- if( !$('.error-text').length )
- $('input.error').after('<p class="error-text">請輸入E-mail</p>');
- return false;
- }
- else {
- $('input[name="q3"]:visible').removeClass('error');
- $('.error-text').remove();
- return true;
- }
- }
- return q2_validate() && q3_validate()
- }
|