svk
svk

Reputation: 4553

How to hide a value in a textbox?

I am showing the value in the textbox.The value comes from the database first I'm storing it in the variable.I have three radio buttons and when the user click third radio button the textbox will be disabled.At that time I want to hide the textbox value displayed within the textbox.**But not to set it NULL.How can I do **Using Jquery?

Upvotes: 0

Views: 2466

Answers (4)

Jay Jani
Jay Jani

Reputation: 11

$(#my_id).click(function(){
    if (!$(this).is(':checked')) {
        $("#amount").val("");
    }else {
        $("#amount").val(YOUR_OWN_VALUE)
    }

}

So simple and easy. Try this.

Upvotes: 1

jay
jay

Reputation: 10325

You could use a hidden field to store the value that you create on the fly:

$("#thirdRadioId").click(function(){
    $("#textInputId").after('<input type="hidden" value="' + $("#textInputId").val() + '" />').val("").attr("disabled", "disabled");
});

You would have to build some functionality to undo this if the user then selects a different radio button.

Upvotes: 2

Pekka
Pekka

Reputation: 449465

How about 1. disabling it the normal way (.disabled = true) and then giving the textbox a "transparent" text color?

Upvotes: 0

eugeneK
eugeneK

Reputation: 11116

Why won't you save current value attribute to a variable and then set input.value property to empty string ?

Upvotes: 0

Related Questions