I have a simple list with a single line of text column. I have a JS function that reads data from other list an set default value for this column in the new form. I simply use.


All works well, if I change my column type and set "Require that this column contains information" to true, the code no longer works. Anyone knows why and how I can get around this issue?


1 Answer 1


When you make the the field required it changes the title attribute of field element . So the selector you are using does not return any element.

You can see the title of the field by inspecting respective textbox/select element on new form in developer tool.

Try using below selectors:

Using Title property:

$("select[title='Fieldname Required Field']").val("Value");

Here Fieldname is display name of field.

Using Id property:

Using Id for element selector is bit tricky in SharePoint as it appends unnecessary string in id attribute by default.


^ denotes that id starts with your Fieldname (Internal name of field). You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

  • That is amazing, thank you so much. I used $(“select[id=’Fieldid']”).val(‘Value’); so I dont have to worry about updating the title Commented Nov 1, 2018 at 5:09
  • Yes, but using Id for element selector is bit tricky in SharePoint. see updated answer. Commented Nov 1, 2018 at 6:26
  • @samSahelly If this answer helped you in any way then please accept an answer so that other users can get help from accepeted answer easily. Commented Nov 1, 2018 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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