Select two elements in each to pick up timeInicio and End of screen inputs

Asked

Viewed 19 times

1

I have a page where I have start and end date, and I need to create a validation where you can’t create any record if the current time is between these two dates.

I have the current date already and am managing to validate with the end time, at $('.horaFim'). each.

Can I get the hourFim and scheduleInicio in the same each? The two have the class hour, but one with the class "Horainico" and another with the "Horafim".

Tks ;>

I am validating with Javascript as follows.

var horaAtual=  horas+':'+minutos; // obtenho a data atual

    var Inicio = null; 
    var aponta = true;

    $('.horaFim').each(function (){
        Fim = $(this).val();
        if(Fim > horaAtual){
             $('.horaFim').each(function (){
                Inicio = $(this).val();

                if(Inicio > horaAtual){
                    $('.possuiapontamento').show();
                    aponta = false;
                }

             })
        }            
    })


    if(aponta == true){            
        $.ajax({
                type      : 'post', 
                url       : 'clock.php', 
                dataType  : 'html',
                data: {hora: horaAtual, id: id, statusClock: statusClock},
                success: function( data ){       
                    diaSemana();                         
                }, 
                error: function(xhr) {alert('Erro ao passar variavel: ' + xhr.responseText);}
            });
    }
  • If the point was just to take the 2 in the same each, you can do this: $('.Horainico', .horaFim). each(/.../); or $('.hour'). each(/.../);

  • Yes, but I am not able to assign the Start value in the variable x and timeFim in the variable y, they are coming in the same. EX: Fim = $('.Fim'). val(); Inicio = $('.Inicio'). val();

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.