0

i cant get the issue in my code , every thing working proper but issue is that when user click or focus first time on textbox correct img show .. this is incorrect but i cant solved this problem when user typing then after completing wher user correct type then show otherwise not shown . can any one help me regarding this issue . my complete jquery and html or css code are available in this link pls check and solved my issue

my code link

i think error on this function but icant get the issue

$('#step1 #fName').focus(function(){

        if($('#step1 #fName').hasClass('error_Aplha')==true)
        {
            $('#step1 #fntick').removeClass('block');    
        }
        else {
            $('#step1 #fntick').addClass('block');
        }
    }).blur(function(){

        if($('#step1 #fName').hasClass('error_Aplha')==true)
        {
            $('#step1 .fname_error').fadeIn(100).delay(2000).fadeOut(1000);
            $('#step1 #fntick').removeClass('block');    
        }
        else {
            $('#step1 .fname_error').removeClass('block');    
            $('#step1 #fntick').addClass('block');
        }

    });

thanks in advance

1 Answer 1

1

Wow, that's a lot of code for a simple task. Change it so the checks are only done in the .keyup() and .blur() events of the INPUT elements.

Not 100% sure what the intended behaviour is, but this will probably get you going:

$(document).ready(function(e) {

    var errorAlpha = function() {
        var reg = /^([A-Za-z]+)$/;
        var check = $(this).val();
        if (reg.test(check) == true && check.match(reg) != null) {
            // VALID
            $(this).removeClass('error_Aplha');
            $(this).next('img').addClass('block');
            $(this).prevAll('span.tooltip2').stop(true).delay(500).fadeOut(400);
        } else {
            // INVALID
            $(this).addClass('error_Aplha');
            $(this).next('img').removeClass('block');
            $(this).prevAll('span.tooltip2').fadeIn(500).delay(2000).fadeOut(1000);
        }
    };

    $('#step1 #fName, #step1 #lName').on('keyup blur', errorAlpha);

});​

Demo: http://jsfiddle.net/gU3PU/6/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.