0

Hello,
I want to use highlight / blick in validation.
below is the validation function.
I have just focused that fields but i want to
highlight that fields and on click of it highlight should remove.
I tried it in first condition but not working.

    function validation_summary_page()
    {
        var total_rows=document.getElementById('SkillDetails_table').rows.length;
        total_rows=total_rows-1;

        for(validation_index=0;validation_index<total_summary_rows;validation_index++)
        {
            if(document.getElementById('prof_level-'+validation_index).value == '')
            {
                alert("Please Profecency level ");
                $('prof_level-'+validation_index).css({'background':'red'}); // it is not working
                return false;
            }

            if(document.getElementById('exp_year-'+validation_index).value == 0 && document.getElementById('exp_months-'+validation_index).value == 0)
            {
                alert("Please select experience. Should have at least 1 month exp. ");
                // instead of focus highlight the field
                document.getElementById('exp_months-'+validation_index).focus();

                return false;
            }
        }
    }
2
Contributors
1
Reply
18
Views
3 Years
Discussion Span
Last Post by AleMonteiro
0

Check out the comments

if(document.getElementById('prof_level-'+validation_index).value == '')
            {
                alert("Please Profecency level ");
                // If prof_level-'+validation_index is the ID, then you missed the # ('#' is the jquery selector for ID)
                $('#prof_level-'+validation_index).css({'background':'red'}); // it is not working
                return false;
            }
            if(document.getElementById('exp_year-'+validation_index).value == 0 && document.getElementById('exp_months-'+validation_index).value == 0)
            {
                alert("Please select experience. Should have at least 1 month exp. ");
                // instead of focus highlight the field
                document.getElementById('exp_months-'+validation_index).style.background = "red" // Obs. I don't remember if 'style' is captioned ('S') or not, I think in some older browsers it were
                                                                            // or backgroundColor
                return false;
            }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.