RadMaskedTextBox and Javascript reset method

8 posts, 0 answers
  1. Sreedath Kuttan
    Sreedath Kuttan avatar
    11 posts
    Member since:
    Jun 2008

    Posted 16 Jun 2008 Link to this post

    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??
  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 17 Jun 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Frankie
    Frankie avatar
    9 posts
    Member since:
    Jan 2008

    Posted 02 Jul 2008 Link to this post

    hi how can i update RadMaskedTextBox's value using client event javascipt?
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 02 Jul 2008 Link to this post

    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
  6. Frankie
    Frankie avatar
    9 posts
    Member since:
    Jan 2008

    Posted 02 Jul 2008 Link to this post

    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;

    }

  7. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 07 Jul 2008 Link to this post

    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
  8. Karl
    Karl avatar
    1 posts
    Member since:
    Jul 2008

    Posted 09 Jul 2008 Link to this post

    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.
  9. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 10 Jul 2008 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017