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

RadMaskedTextBox and Javascript reset method

7 Answers 217 Views
Input
This is a migrated thread and some comments may be shown as answers.
Sreedath Kuttan
Top achievements
Rank 1
Sreedath Kuttan asked on 16 Jun 2008, 01:13 PM
Hi,
    I am working with the RADMASKEDTEXTBOX with a mask value of ###-###-####
on calling the document.forms[0].reset(),the value of the textbox becomes -- and the regularexpression validator fires.Can this be avoided??

7 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 17 Jun 2008, 10:53 AM
Hi Sreedath,

The reset() method resets all form elements to their initial values, when the page has been loaded. This happens at a lower level, i.e. the MaskedTextBox is not aware of this and the control's API cannot be used to prevent resetting its value.

However, you can implement a custom scenario, for example, store the textbox' value in a variable, call the reset() method and then restore the textbox value again using the control's API.


All the best,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Frankie
Top achievements
Rank 2
answered on 02 Jul 2008, 10:12 AM
hi how can i update RadMaskedTextBox's value using client event javascipt?
0
Sebastian
Telerik team
answered on 02 Jul 2008, 10:14 AM
Hi Frankie,

To udpate the RadMaskedTextBox value on the client utilize the set_value() method from its client-side API.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Frankie
Top achievements
Rank 2
answered on 02 Jul 2008, 12:05 PM
Dear Stephen,

The following is my script called from the RadMaskTextBox, it is with error.

function CheckJoinDateInput(sender, eventArgs)

{

unit =

"years";

var joindate = eventArgs.get_newValue();

var _mon = joindate.substring(0,2);

var _yr = joindate.substring(3,8);

var mon = parseInt(_mon);

var yr = parseInt(_yr);

var today = new Date();

var todaymonth = today.getMonth() + 1;

var todayyear = today.getFullYear();

var newjoindate = ""

if (yr == todayyear){

if (mon > todaymonth)

_mon = todaymonth.toString();

mon = todaymonth;

}

if (mon < 10)

_mon =

"0" + mon.toString();

newjoindate = _mon +

"/" + yr.toString();

//eventArgs.set_value(joindate);   <----

document.getElementById(

"joindate").innerHTML = newjoindate;

}

0
Daniel
Telerik team
answered on 07 Jul 2008, 11:38 AM
Hi Frankie,

eventArgs does not contain such a method. set_value is a client-side function of the sender argument(RadMaskedTextBox). Hence it is neccessary to use sender.set_value() instead of eventArgs.set_value().

Best,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Karl
Top achievements
Rank 1
answered on 09 Jul 2008, 01:18 PM
Hi Dimo.

You say "The reset() method resets all form elements to their initial values, when the page has been loaded". I have a radtextbox (and a standard html textbox for comparison) both of which have values preloaded server-side for the user to edit. There is also a reset button to undo their client-side changes.

What I am used to with html and asp.net forms is that upon making changes then clicking the reset button the textbox changes are undone and it reverts to the original text as preloaded by the server. With a standard html textbox this remains the case and the original text reappears but with a radtextbox on the same form the field is left empty. If I then click into the radtextbox field the instant I do so the text reappears (the correct preloaded server-side content) as if it were there all the time.

Any ideas as to how to get around this and have the text not vanish?

I am using IE7. I would love to test it in Firefox and Safari but cannot currently due to AjaxControlToolkit being undefined errors - but that's another issue.
0
Dimo
Telerik team
answered on 10 Jul 2008, 12:06 PM
Hi Karl,

I was unable to reproduce the described issue - the value of the radtextboxes always reverts to the initial state and does not disappear on executing form.reset().

Please open a support ticket to send us a sample web page, or paste your ASPX code here. Thanks.

Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Input
Asked by
Sreedath Kuttan
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Frankie
Top achievements
Rank 2
Sebastian
Telerik team
Daniel
Telerik team
Karl
Top achievements
Rank 1
Share this question
or