I am with two textbox but wanted to make when one of them lose focus disables the other. this code works on components vb 2010 example:
$('#<%= RadTextBox2.ClientID %>').change(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl1.val() == "") {
targetControl1.attr('disabled', 'disabled');
}
});
$('#<%= RadTextBox2.ClientID %>').focusin(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl2.val() == "") {
targetControl1.removeAttr('disabled', 'disabled');
}
});
$('#<%= RadTextBox1.ClientID %>').change(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl2.val() == "") {
targetControl2.attr('disabled', 'disabled');
}
});
$('#<%= RadTextBox1.ClientID %>').focusin(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl1.val() == "") {
targetControl2.removeAttr('disabled', 'disabled');
}
});
no works !
$('#<%= RadTextBox2.ClientID %>').change(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl1.val() == "") {
targetControl1.attr('disabled', 'disabled');
}
});
$('#<%= RadTextBox2.ClientID %>').focusin(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl2.val() == "") {
targetControl1.removeAttr('disabled', 'disabled');
}
});
$('#<%= RadTextBox1.ClientID %>').change(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl2.val() == "") {
targetControl2.attr('disabled', 'disabled');
}
});
$('#<%= RadTextBox1.ClientID %>').focusin(function (e) {
var targetControl1 = $('#<%= RadTextBox1.ClientID %>');
var targetControl2 = $('#<%= RadTextBox2.ClientID %>');
if (targetControl1.val() == "") {
targetControl2.removeAttr('disabled', 'disabled');
}
});
no works !
21 Answers, 1 is accepted
0

Kevin
Top achievements
Rank 2
answered on 16 Jan 2012, 02:49 PM
Hello Toboy,
If you're using the latest version of RadControls, you should turn on EnableSingleInputRendering="true", in order to access the input element as you have it now, otherwise you will need to append "_text" to your id's, as that's how you access the input element when EnableSingleInputRendering is turned off.
I hope that helps.
If you're using the latest version of RadControls, you should turn on EnableSingleInputRendering="true", in order to access the input element as you have it now, otherwise you will need to append "_text" to your id's, as that's how you access the input element when EnableSingleInputRendering is turned off.
I hope that helps.
0

Kevin
Top achievements
Rank 2
answered on 16 Jan 2012, 02:51 PM
To add to my previous post, you could also handle the OnValueChanging/OnValueChanged and OnFocus events of the RadTextBox to achieve the same result. You will just need to use the RadTextBox client-side api to toggle the disabled state and check that control's value.
0

Toboy
Top achievements
Rank 1
answered on 25 Jan 2012, 02:48 PM
Can you give me an example of how my code would be because I tried but I will get the version I'm using v.2011.3.1115.40 will be grateful!
0
Hi Toboy,
Here is an example:
Check this help topic for more information on the client side functions of RadInput's object:
http://www.telerik.com/help/aspnet-ajax/input-client-side-radtextbox.html
Regards,
Vasil
the Telerik team
Here is an example:
var
input1= $find(
'<%= RadTextBox1.ClientID %>'
);
input1.disable();
http://www.telerik.com/help/aspnet-ajax/input-client-side-radtextbox.html
Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Toboy
Top achievements
Rank 1
answered on 25 Jan 2012, 06:56 PM
I am new to java can be more clear where I call this code <telerik: RadTextBox id = "RadTextBox2" runat = "server" Height = "15px" Width = "300px"
ValidationGroup = "Representative" onvaluechange = "btnSend_onclick"> </ telerik: RadTextBox>
btnSend_onclick function () {
var input1 = $ find ('<%= RadTextBox1.ClientID %>');
input1.disable ();
var input1 = $ find ('<%= RadTextBox2.ClientID %>');
input1.disable ();
}
and <telerik: RadTextBox id = "RadTextBox1" runat = "server" Height = "15px" Width = "300px"
ValidationGroup = "Representative" onvaluechange = "btnSend_onclick"> </ telerik: RadTextBox>
Remembering that my purpose is when a RadTextBox lose focus and disable the other and enabled RadTextBox2
Can you help me how will be my code.
ValidationGroup = "Representative" onvaluechange = "btnSend_onclick"> </ telerik: RadTextBox>
btnSend_onclick function () {
var input1 = $ find ('<%= RadTextBox1.ClientID %>');
input1.disable ();
var input1 = $ find ('<%= RadTextBox2.ClientID %>');
input1.disable ();
}
and <telerik: RadTextBox id = "RadTextBox1" runat = "server" Height = "15px" Width = "300px"
ValidationGroup = "Representative" onvaluechange = "btnSend_onclick"> </ telerik: RadTextBox>
Remembering that my purpose is when a RadTextBox lose focus and disable the other and enabled RadTextBox2
Can you help me how will be my code.
0
Hello Toboy,
Here is an workable sample. After the page loads, the TextBox2 gets disabled. Then when you enter value in the TextBox1, it get disabled, and the TextBox2 becomes enabled.
Regards,
Vasil
the Telerik team
Here is an workable sample. After the page loads, the TextBox2 gets disabled. Then when you enter value in the TextBox1, it get disabled, and the TextBox2 becomes enabled.
<
script
type
=
"text/javascript"
>
function textBox1valueChanged(sender, args)
{
sender.disable();
var textBox2 = $find("<%=RadTextBox2.ClientID %>");
textBox2.enable();
}
function disableThis(sender, args)
{
sender.disable();
}
</
script
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"RadTextBox1"
>
<
ClientEvents
OnValueChanged
=
"textBox1valueChanged"
/>
</
telerik:RadTextBox
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"RadTextBox2"
>
<
ClientEvents
OnLoad
=
"disableThis"
/>
</
telerik:RadTextBox
>
Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Toboy
Top achievements
Rank 1
answered on 26 Jan 2012, 12:41 PM
Sorry but what I wanted was for both to stay active on page load only be disabled when entering some value in a field. example:
when I type in the textbox1 textbox2 the disabled and when I goes out the contents of a textbox to enable the textbox 2 and so respectively.
I have a study that textbox1 from codes and performs textbox2 by description, when one of them disables the other is filled by the two can not seek the same time
when I type in the textbox1 textbox2 the disabled and when I goes out the contents of a textbox to enable the textbox 2 and so respectively.
I have a study that textbox1 from codes and performs textbox2 by description, when one of them disables the other is filled by the two can not seek the same time
0

Toboy
Top achievements
Rank 1
answered on 26 Jan 2012, 01:16 PM
your code works only when I disable the postback it is my intention to disable it the other field only when it lose focus, because when I disable the postback it the same field that I'm using.
0

Toboy
Top achievements
Rank 1
answered on 26 Jan 2012, 02:16 PM
I tried but did not work this way: he wanted to disable only when you lose your focus
<script type=
"text/javascript"
id=
"telerikClientEvents5"
>
//<![CDATA[
function
RadTextBox1_OnFocus(sender,args)
{
var
textBox2 = $find(
"<%=RadTextBox2.ClientID %>"
);
textBox2.enable();
if
(textBox2.val() ==
""
) {
sender.disable();
}
}
//]]>
</script>
<script type=
"text/javascript"
id=
"telerikClientEvents6"
>
//<![CDATA[
function
RadTextBox2_OnFocus(sender,args)
{
var
textBox1 = $find(
"<%=RadTextBox1.ClientID %>"
);
textBox1.enable();
if
(textBox1.val() ==
""
) {
sender.disable();
}
//]]>
</script>
0
Hi,
If you want to perform action on loosing focus, you could use the Blur event:
http://www.telerik.com/help/aspnet-ajax/input-client-side-onblur.html
Greetings,
Vasil
the Telerik team
If you want to perform action on loosing focus, you could use the Blur event:
http://www.telerik.com/help/aspnet-ajax/input-client-side-onblur.html
Greetings,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Toboy
Top achievements
Rank 1
answered on 27 Jan 2012, 02:00 AM
how would my code to disable the textbox when it loses its focus, as I said I am new to java can help me, I tried to introduce what I already had and did not work .
example :
$(
'#<%= RadTextBox2.ClientID %>'
).change(
function
(e)
{
var
targetControl1 =
$('
#<%= RadTextBox1.ClientID
%>');
var
targetControl2
= $('
#<%= RadTextBox2.ClientID
%>');
if
(targetControl1.val() ==
""
)
{
targetControl1.attr(
'disabled'
,
'disabled'
);
}
});
0
Hi Toboy,
Here is an example how to disable the RadTextBox after it loses its focus.
All the best,
Vasil
the Telerik team
Here is an example how to disable the RadTextBox after it loses its focus.
<
script
type
=
"text/javascript"
>
function RadTextBox1BlurHandler(sender, args)
{
sender.disable();
}
</
script
>
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
>
<
ClientEvents
OnBlur
=
"RadTextBox1BlurHandler"
/>
</
telerik:RadTextBox
>
All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Toboy
Top achievements
Rank 1
answered on 28 Jan 2012, 03:06 PM
and if I want to use it again after he lost the focus I just click on it it works ?
0
Hi Toboy,
You can not click it later, because it is disabled. In order to be able to click it, you need to enable it first.
However from what you written, I believe that you need to style the textbox differently depending if it is on focus or not, and not to disable it. If I am correct in this assumption please see these resources:
http://www.telerik.com/help/aspnet-ajax/input-styles.html
http://demos.telerik.com/aspnet-ajax/input/examples/appearance/styles/defaultcs.aspx
All the best,
Vasil
the Telerik team
You can not click it later, because it is disabled. In order to be able to click it, you need to enable it first.
However from what you written, I believe that you need to style the textbox differently depending if it is on focus or not, and not to disable it. If I am correct in this assumption please see these resources:
http://www.telerik.com/help/aspnet-ajax/input-styles.html
http://demos.telerik.com/aspnet-ajax/input/examples/appearance/styles/defaultcs.aspx
All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Toboy
Top achievements
Rank 1
answered on 06 Feb 2012, 01:33 PM
and how do I enable it again in my old code enabled the textbox that he was disabled when the fields were clean he would return to work, as I have to do this check in your code
0
Hello Toboy,
Well to enable the RadTextBox you could use the .enable() function like:
If you still have troubles with your implementation, please give us more detailed explanations of the scenario that you want to achieve. When you need to disable the textboxes, and when you need to enable them? Are they are only two textboxes? Do you need to change the enable/disable state of one of them depending changes of the other one?
All the best,
Vasil
the Telerik team
Well to enable the RadTextBox you could use the .enable() function like:
var
textBox1 = $find(
"<%=RadTextBox1
.ClientID %>"
);
textBox1.enable();
If you still have troubles with your implementation, please give us more detailed explanations of the scenario that you want to achieve. When you need to disable the textboxes, and when you need to enable them? Are they are only two textboxes? Do you need to change the enable/disable state of one of them depending changes of the other one?
All the best,
Vasil
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0

Toboy
Top achievements
Rank 1
answered on 10 Feb 2012, 06:09 PM
must activate when the boxes are off and you were doing when one of the boxes have been chosen
example: I have two search fields radtextbox a search for the code part 2 radtextbox search for part description
when the User to choose a radtextbox radtextbox 2 is disabled and is cleared when the radtextbox both fields should be activated
example: I have two search fields radtextbox a search for the code part 2 radtextbox search for part description
when the User to choose a radtextbox radtextbox 2 is disabled and is cleared when the radtextbox both fields should be activated
0
Hi,
So you need to disable the other textbox when the first one has text entered. And if they both are empty they should be enabled. If this is correct, here is the code:
Regards,
Vasil
the Telerik team
So you need to disable the other textbox when the first one has text entered. And if they both are empty they should be enabled. If this is correct, here is the code:
<
script
type
=
"text/javascript"
>
function rtb1BlurHandler(sender, args)
{
if (sender.get_value() == "")
$find("<%=rtb2.ClientID %>").enable();
else
$find("<%=rtb2.ClientID %>").disable();
}
function rtb2BlurHandler(sender, args)
{
if (sender.get_value() == "")
$find("<%=rtb1.ClientID %>").enable();
else
$find("<%=rtb1.ClientID %>").disable();
}
</
script
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"rtb1"
ClientEvents-OnBlur
=
"rtb1BlurHandler"
>
</
telerik:RadTextBox
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"rtb2"
ClientEvents-OnBlur
=
"rtb2BlurHandler"
>
</
telerik:RadTextBox
>
Regards,
Vasil
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0

Toboy
Top achievements
Rank 1
answered on 17 Feb 2012, 07:36 PM
exactly the same thanks for the help
0

Toboy
Top achievements
Rank 1
answered on 27 Feb 2012, 09:00 PM
each textbox I have a button I use, I can make the textbox to be populated he can give the focus on the desired button example:
<
script
type
=
"text/javascript"
>
function rtb1BlurHandler(sender, args)
{
if (sender.get_value() == "")
$find("<%=rtb2.ClientID %>").enable();
RadButton1.focus
else
$find("<%=rtb2.ClientID %>").disable();
0
Hi Toboy,
To focus the button you could use its focus() method like:
For more information see this help topic:
http://www.telerik.com/help/aspnet-ajax/button-client-side-basics.html
Greetings,
Vasil
the Telerik team
To focus the button you could use its focus() method like:
$find(
"<%=RadButton1.ClientID %>"
).focus();
http://www.telerik.com/help/aspnet-ajax/button-client-side-basics.html
Greetings,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.