I have added a textbox to SharePoint as part of my project(<input id="Text1" class="textbox" style="" type="text" readonly />). I need to show hide the text box based on certain condition. i am unable to do so based with below document.getElementById("Text1").style.display = 'none'; or document.getElementById("Text1").style.display = 'block';

both are not working.

i have attempted to remove border and put an under line to the text box. But for some reason the below styling is not working with SharePoint.

outline: none;

  • Did you checked the id of your textbox in F12 Development Tools ? Did you add ClientIDMode="Static" to static to your textbox ? – Youssef Moumen El idrissi Jan 28 '18 at 11:17
  • Tried that the id is showing as Text1. if i add <input id="Text1" class="textbox" style="display : none" type="text" readonly /> i can see the textbox is not visible any more, but at the same time document.getElementById("Text1").style.display = 'block'; or none doesnt work when i reach document.getElementById("Text1").style and put a dot the intellisense does not show display for some reason. – Rinu Jan 28 '18 at 11:30
  • i have added as advised <input id="Text1" class="textbox" style="" ClientIDMode="Static" type="text" readonly /> but still the same. – Rinu Jan 28 '18 at 11:32
  • I thought that you work with asp.net textbox control anyway try this jquery code : $("input#Text1").hide(); normally it works if not check if the condition is realized or not. – Youssef Moumen El idrissi Jan 28 '18 at 12:05

“document.getElementById("Text1").style.display = 'none'” should work fine. Where do you add the JS code? Directly in the page? Have you added script type="text/javascript" tab? Make sure that your JS has been executed.

How about “border:none;”?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.