alcatrazbr
5/16/2015 - 11:39 PM

js verificaform

js verificaform

<script>
  function verificaform(){
    showhelp($("#edtNome"), 3);
    showhelp($("#edtEmail"), 5);
    showhelp($("#edtTel"), 8);
    showhelp($("#frmCliente #edtPassword"), 6);
    showhelp($("#frmCliente #edtConfirme"), 6);
    igual($("#frmCliente #edtPassword"), $("#frmCliente #edtConfirme"));
    showhelp($("#edtCep"), 9);
    showhelp($("#edtEndereco"), 5);
    showhelp($("#edtNro"), 1);
    showhelp($("#edtBairro"), 4);
    showhelp($("#edtCidade"), 2);

    if (frmErro) {
      $(".help").show()
      return false;
    } else {
      $(".help").hide()
      $("input").removeAttr('disabled');
      $("#frmCliente").submit();
    }
  }

  function igual(pass, confirme){
    if (pass.val() != confirme.val()) {
      pass.prev().removeClass('text-success').addClass('text-danger');
      pass.offsetParent().removeClass('has-warning').addClass('has-error');
      pass.prev().html('<span class="glyphicon glyphicon-remove"></span> Senhas devem coincidir');

      confirme.prev().removeClass('text-success').addClass('text-danger');
      confirme.offsetParent().removeClass('has-warning').addClass('has-error');
      confirme.prev().html('<span class="glyphicon glyphicon-remove"></span> Senhas devem coincidir');

      return true;
    }
  }

  function showhelp(seletor, size){
    if (seletor.val().length < size){
      seletor.offsetParent().removeClass('has-warning').addClass('has-error');
      frmErro = true;
      return true;
    } else {
      seletor.offsetParent().removeClass('has-error has-warning').addClass('has-success');
      seletor.prev().removeClass('text-danger').addClass('text-success');
      seletor.prev().children().removeClass('glyphicon-remove').addClass('glyphicon-ok');
      return false;
    }
  }
</script>
    <div class="row form-group">
      <div class="col-xs-4 has-warning">
          <label for="edtNome" class="text-danger help"><span class="glyphicon glyphicon-remove"></span> Obrigatório</label>
          <input type="text" class="form-control input-lager" id="edtNome" name="Nome" placeholder="Digite seu nome">
      </div>
      <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8 has-warning">
         <label for="edtEmail" class="text-danger help"><span class="glyphicon glyphicon-remove"></span> Obrigatório</label>
         <input type="email" id="edtEmail" name="Email" class="form-control" value="" placeholder="voce@provedor.com.br">
      </div>
    </div>