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;
            }
        }
    }

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;
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.