0

I have a textbox with some css property created by formHandler method. When I check the textbox is empty and I applied another css class for red color in the border through jquery code is below

 $('a,button').click(function () {
        if($("#FHE_0_first_name").val()=="")
            {
            $("#FHE_0_first_name").addClass("errorCSS");
            }
    });

and my css is below

.errorCSS
{
    clear:both;
    border:1px solid #ff0000 !important;
    background-color:#ffeeee !important;

}

The red color and background color just come and disappered how can i keep the neww css .

appreciated all suggestions

2
  • perhaps you should make a jsFiddle so we have a model to play with Commented May 16, 2012 at 18:22
  • from what you are saying it sounds like the style is being applied correctly but later on the style is being lost. could you be more specific? Commented May 16, 2012 at 18:30

1 Answer 1

1

First you'll need to change your $(a,button) selector to $(a.button).

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

4 Comments

That's because the page will subit through 2 way one for a href and another for button click.I am tracking both the events.
$('a,button') is legit. it will select any anchor or button tag. see: jsfiddle.net/6r6cg
I am getting the alert inside the function and even the css is also affected for a quick moment that is at the time of button click
You are right it will select any anchor tag...i need to modify that too..My a href is something like below <a onclick="adc.FormHandler.goto('user_edit', 1); return false;" href="#"> <i class="icon-tab-num" data="2"></i> Account Details </a>

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.