locked
How to enable/disable a datetime attribute by Javascript RRS feed

  • Question

  • Hello guys,

    I just one requirement to enable/disable datetime attributes by javascript.

    I tried:

    document.getElementById(

    attributeName).disabled = true

    document.getElementById(

    attributeName).childNodes[0].childNodes[0].disabled = false;

    with no success.

    Any ideas ?

     


    Yojan
    Wednesday, March 31, 2010 4:18 PM

Answers

  •  

    It is a capital D:

    document.getElementById(

     

    attributeName).Disabled = true
    • Marked as answer by Yojan Wednesday, March 31, 2010 4:30 PM
    • Unmarked as answer by Yojan Wednesday, March 31, 2010 5:22 PM
    • Proposed as answer by Blake ScarlavaiMVP Wednesday, March 31, 2010 8:17 PM
    • Marked as answer by Jim Glass Jr Wednesday, March 31, 2010 9:44 PM
    Wednesday, March 31, 2010 4:21 PM
  • usually I do:

    if (crmForm.all.attributename)
    {
       crmForm.all.attributename.Disabled = true;
    }


    That will work, even on DateTime fields and won't allow the user to input any value either from the image or input box.


    If you need the value to save then add the line:

    crmForm.all.attributename.ForceSubmit = true;

    Wednesday, March 31, 2010 6:46 PM
    • Proposed as answer by HIMBAPModerator Wednesday, March 31, 2010 7:04 PM
    • Marked as answer by Jim Glass Jr Wednesday, March 31, 2010 9:44 PM
    Wednesday, March 31, 2010 7:04 PM
    Moderator

All replies

  •  

    It is a capital D:

    document.getElementById(

     

    attributeName).Disabled = true
    • Marked as answer by Yojan Wednesday, March 31, 2010 4:30 PM
    • Unmarked as answer by Yojan Wednesday, March 31, 2010 5:22 PM
    • Proposed as answer by Blake ScarlavaiMVP Wednesday, March 31, 2010 8:17 PM
    • Marked as answer by Jim Glass Jr Wednesday, March 31, 2010 9:44 PM
    Wednesday, March 31, 2010 4:21 PM
  • Thanks ..

    But Disable ... Does not afect input part of the datetime attribute, so any changes given by clicking image is not saved despite this sentence ForceSubmit before saving.

    Another approach is by using:

    propertyimg.disabled =

    true; but I can not control input control

    any ideas ..

     

     

    Wednesday, March 31, 2010 4:30 PM
  • usually I do:

    if (crmForm.all.attributename)
    {
       crmForm.all.attributename.Disabled = true;
    }


    That will work, even on DateTime fields and won't allow the user to input any value either from the image or input box.


    If you need the value to save then add the line:

    crmForm.all.attributename.ForceSubmit = true;

    Wednesday, March 31, 2010 6:46 PM
    • Proposed as answer by HIMBAPModerator Wednesday, March 31, 2010 7:04 PM
    • Marked as answer by Jim Glass Jr Wednesday, March 31, 2010 9:44 PM
    Wednesday, March 31, 2010 7:04 PM
    Moderator
  • Thanks,

    this post http://customerfx.com/pages/crmdeveloper/2006/03/06/17312.aspx just controls image button but not input one.


    Yojan
    Wednesday, March 31, 2010 8:12 PM
  • Yes, disabled all lowercase will just make the input read-only.  Disabled with a capital D will make both the input and image read-only.
    Wednesday, March 31, 2010 8:16 PM