Jump to content


Photo

Problemas Fancy Sliding Form Com Jquery.... Botao Submit.


  • Faça o login para participar
Nenhuma resposta neste tópico

#1 Dinho.

Dinho.

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Masculino
  • Localidade:Curitiba

Posted 21/05/2011, 13:15

Bem vamos direto ao ponto...

Nos navegadores, IEca, Mozilla, apos fazer a validacao dos campos, o botao submit funciona perfeitamente..
so que no chrome ele nao ta funfado... Talvez seja algum erro do java ou algo assim..
eu nao sei nada de java .. entao me perdoem pela minha ignorância em relacao ao assunto.

Contato.php
<div id="wrapper">
                <div id="steps">
                    <form id="formElem" name="formElem" action="enviar.php" method="post">
                        <fieldset class="step">
                            <legend>Info</legend>
                            <p>
                                <label for="empresa">Empresa</label>
                                <input id="empresa" name="empresa" />
                            </p>
                            <p>
                                <label for="email">Email</label>
                               <input id="email" name="email" placeholder="voxx@seuemail.com" type="email" AUTOCOMPLETE=OFF />
                            </p>
                            <p>
                                <label for="assunto">Assunto</label>
                              <input id="assunto" name="assunto" type="assunto" AUTOCOMPLETE=OFF />
                            </p>
                        </fieldset>
                        <fieldset class="step">
                           <legend>Dados Pessoais</legend>
                            <p>
                                <label for="nome">Nome Completo</label>
                                <input id="nome" name="nome" type="text" AUTOCOMPLETE=OFF />
                           </p>
                            <p>
                                <label for="cidade">Cidade</label>
                               <input id="cidade" name="cidade" type="text" AUTOCOMPLETE=OFF />
                          </p>
                          <p>
                                <label for="telefone">Telefone</label>
                               <input id="telefone" name="telefone" placeholder="41 3333-2222" type="tel" AUTOCOMPLETE=OFF />
                            </p>
                        </fieldset>
                        <fieldset class="step">
                           <legend>Dúvidas, Críticas, Sugestões</legend>
                            <p>
                                <textarea id="mensagem" name="mensagem" rows="10" style="width:388px;"> </textarea>
                            </p>
                          
                        </fieldset>
         <fieldset class="step">
                            <legend>Enviar</legend>
                                                
                            <p>
                             Obrigado por entrar em contato conosco, estaremos 
                             retornando o mais rapido possivel.
                             Att. VoxxDesign.com
							</p>

                             <p class="submit"> 
                                <button id="registerButton"  type="submit" value="Enviar">Enviar</button>
                             </p>
                          
                        </fieldset>
                    </form>                   
                        
                </div>
                <div id="navigation" style="display:none;">
                    <ul>
                        <li class="selected">
                            <a href="#">Info</a>
                        </li>
                        <li>
                            <a href="#">Dados Pessoais</a>
                        </li>
                        <li>
                            <a href="#">Mensagem</a>
                        </li>
                        <li>
                            <a href="#">Enviar</a>
                        </li>
                    </ul>
                </div>
            </div>


Java
$(function() {
	/*
	number of fieldsets
	*/
	var fieldsetCount = $('#formElem').children().length;

	/*
	current position of fieldset / navigation link
	*/
	var current 	= 1;

	/*
	sum and save the widths of each one of the fieldsets
	set the final sum as the total width of the steps element
	*/
	var stepsWidth	= 0;
    var widths 		= new Array();
	$('#steps .step').each(function(i){
        var $step 		= $(this);
		widths[i]  		= stepsWidth;
        stepsWidth	 	+= $step.width();
    });
	$('#steps').width(stepsWidth);

	/*
	to avoid problems in IE, focus the first input of the form
	*/
	$('#formElem').children(':first').find(':input:first').focus();	

	/*
	show the navigation bar
	*/
	$('#navigation').show();

	/*
	when clicking on a navigation link
	the form slides to the corresponding fieldset
	*/
    $('#navigation a').bind('click',function(e){
		var $this	= $(this);
		var prev	= current;
		$this.closest('ul').find('li').removeClass('selected');
        $this.parent().addClass('selected');
		/*
		we store the position of the link
		in the current variable
		*/
		current = $this.parent().index() + 1;
		/*
		animate / slide to the next or to the corresponding
		fieldset. The order of the links in the navigation
		is the order of the fieldsets.
		Also, after sliding, we trigger the focus on the first
		input element of the new fieldset
		If we clicked on the last link (confirmation), then we validate
		all the fieldsets, otherwise we validate the previous one
		before the form slided
		*/
        $('#steps').stop().animate({
            marginLeft: '-' + widths[current-1] + 'px'
        },500,function(){
			if(current == fieldsetCount)
				validateSteps();
			else
				validateStep(prev);
			$('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus();
		});
        e.preventDefault();
    });

	/*
	clicking on the tab (on the last input of each fieldset), makes the form
	slide to the next step
	*/
	$('#formElem > fieldset').each(function(){
		var $fieldset = $(this);
		$fieldset.children(':last').find(':input').keydown(function(e){
			if (e.which == 9){
				$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
				/* force the blur for validation */
				$(this).blur();
				e.preventDefault();
			}
		});
	});

	/*
	validates errors on all the fieldsets
	records if the form has errors in $('#formElem').data()
	*/
	function validateSteps(){
		var FormErrors = false;
		for(var i = 1; i < fieldsetCount; ++i){
			var error = validateStep(i);
			if(error == -1)
				FormErrors = true;
		}
		$('#formElem').data('errors',FormErrors);
	}

	/*
	validates one fieldset
	and returns -1 if errors found, or 1 if not
	*/
	function validateStep(step){
		if(step == fieldsetCount) return;

		var error = 1;
		var hasError = false;
		$('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input:not(button)').each(function(){
			var $this 		= $(this);
			var valueLength = jQuery.trim($this.val()).length;

			if(valueLength == ''){
				hasError = true;
				$this.css('background-color','#FFEDEF');
			}
			else
				$this.css('background-color','#FFFFFF');
		});
		var $link = $('#navigation li:nth-child(' + parseInt(step) + ') a');
		$link.parent().find('.error,.checked').remove();

		var valclass = 'checked';
		if(hasError){
			error = -1;
			valclass = 'error';
		}
		$('<span class="'+valclass+'"></span>').insertAfter($link);

		return error;
	}

	/*
	if there are errors don't allow the user to submit
	*/
	$('#registerButton').bind('click',function(){
		if($('#formElem').data('errors')){
			alert('Please correct the errors in the Form');
			
		}
	});
});


Fico no aguardo.. vlwss




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq