Good Day All

i have a Jquery code defined like this

// Let's add it to textarea this time
        $(".cnt").focus(function()
        {
            // Check for the change
            if(this.value == this.defaultValue){
                this.select();
            }
        });

and i am creating a textbox on fly and after creating it i bind data to it and after that i want to attach a focus event if there a value "0" on it

If cnt.Text = "0" Then
            cnt.CssClass = "cnt"
        End If

but still when i select a textbox that has "0" it does not select the whole content of the textbox. i went through a breakpoint and it goes through this line

cnt.CssClass = "cnt"

Thanks

Recommended Answers

All 2 Replies

so is your question is that.

You have a textbox and you define value to it as that can be defaultly be set and if you focus in on the textbox and there is no value define to it should be highlight.Is this the question sir

Member Avatar for stbuchok

This looks like a mix of VB.Net and jQuery, am I correct?


This code is only adding a class to cnt, it is not adding a focus event.

If cnt.Text = "0" Then
            cnt.CssClass = "cnt"
        End If

Please explain in greater detail what you are trying to achieve, don't just show code. You need a proper mix of both in order to get your point across.

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.