This is a migrated thread and some comments may be shown as answers.

Clear Value in Textbox in RadGrid

1 Answer 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atchut
Top achievements
Rank 1
Atchut asked on 23 May 2012, 06:55 PM
Hello,

I am using ClientSide setting to access the value of the RadNumeric Textbox.

If the value is incorrect(according to the business rules), I want to clear the value in Textbox and focus on the textbox.

The value is not getting cleared for me. How to do this ?

Here is my Code

 function ValueChanged(sender, args) {

alert("Incorrect Value");
sender.focus();
//Clear the Textbox Value.
}

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 May 2012, 05:35 AM
Hi Akki,

Try the following Javascript to clear and focus on the RadNumericTextBox if value entered is wrong.

Javascript:
<script type="text/javascript">
    function OnValueChanged(sender, args)
     {
        if (sender.get_value() == "2") {
            alert("Incorrect value");
            sender.clear();
            args.set_cancel(true);
            window.setTimeout(function () { sender.focus(); }, 20);
        }
    }
</script>

Thanks,
Shinu.
Tags
Grid
Asked by
Atchut
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or