I have a calendar app created in SharePoint 2013, I want to Autofill Location text field in popup window of add new event.

How can I do it with help of JavaScript or jQuery?


Follow below steps:

  1. Go to New form page of calendar list form using URL in below format:

  2. Edit the page

  3. Add Script editor/Content editor web part on page

  4. Add below code in web part to auto-populate the Location field on form:

<script type="text/javascript"> 
    function autoPopulateLocation(){
        // your code
        document.querySelector("input[title^='Location']").value = "My custom value";


  1. Save/Stop Editing the page.


enter image description here

Update from comments:

To disable the textbox, use below code:

document.querySelector("input[title^='Location']").disabled = "disabled";

OR with readonly attribute like:

document.querySelector("input[title^='Location']").readOnly = true;
  • Great, it is working, How can i make it diabled? So users cannot retype Jun 15 '21 at 8:40
  • To disable the textbox, use code given in updated answer. Jun 15 '21 at 8:54
  • Also, Please Upvote(^) and accept as an Answer as it helped you & it will help others with similar question in future to find the correct answer easily. Jun 15 '21 at 8:55
  • Sure, I will up vote but i need to signup or need to find login information and sign in. Right now i am i urgent situation, just one more question, your code work fine but i need one more help, after adding the event, it is not taking inforamtion from diabled field and it is coming blank when open or edit it, how can i post data from diable field to the calendar. Jun 15 '21 at 9:03
  • I wonder how you are adding comments here without login :) However, try using readOnly approach from updated answer. Jun 15 '21 at 9:33

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.