I have a textfield in sharepoint list form and I want to set the value using jquery or javascript below is the tag:

<asp:TextBox runat="server" id="ff47{$Pos}" text="{@Name}" __designer:bind="{ddwrt:DataBind('i',concat('ff47',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Name')}" />

I am using this to set var ele = $("input[title='Name']").val("Bob"); but it is not setting the value, any suggestions?

  • This guy wants to set or hardcode a value in a formfield in sharepoint. More clear than water. Does anyone have a solution about this? Regards Pete – user20979 Nov 22 '13 at 19:37
  • Please refer to my answer in Stackoverflow: It worked perfectly: Set value to textbox field – Gláucio Leonardo Sant'ana Feb 8 '18 at 14:16

you might added the extra curly brace to build the MAIN() like the sample below

<script type="text/javascript">
    $(document).ready(function () {

        //program logic


           } // the culprit extra brace



Hope it helps.

| improve this answer | |

You need to Inspect that particular textbox with FireBug or IE Developer tools. If I am right the asp:Textbox is internally converted to an input control which will have a unique attibute. You can use this attribute to pickup the input with JavaScript/jQuery and set the value.

From what I can gather, you are setting the id and the text dynamically by using placeholder variables. I would inspect these two attributes and reference the input field by using one of them.

| improve this answer | |
  • As you could see, his jquery has input in the selector – Colin Feb 2 '12 at 23:59
  • True. But the attributes of the input are being generated dynamically and they need to be picked up correctly with jQuery. – Vardhaman Deshpande Feb 3 '12 at 0:58

Could you post the exact rendered Html? I ask this because usually id and name attribute value contain a crappy generated string. You could try a wildcard in your selector:

var ele = $("input[title='*Name']").val("Bob"); // notice the *
| improve this answer | |

This is an old post, but it is one of the first I found while googling the same problem. If Name is a required field, the proper syntax is:

$("input[value='Name Required Field']").val("Bob");

No, I am not kidding. Thanks again, Microsoft, for making developer's lives a little bit harder.

| improve this answer | |

Try this instead:

| improve this answer | |
  • Hi James,i tried it but it is not working – spStacker Feb 2 '12 at 21:14
  • If Name is a Required Field, you must enter "value='Name Required Field'" instead of just "value='Name'". See my answer. – CigarDoug Jan 23 '17 at 17:04

I really wished to understand what has been asked in this question.
Having too long for a comment misunderstandings I hope the question would be reformulated into more comprehensible one...

The markup of an element (or node but not "tag") does not look to me as part of list form (are there forms for a list at all?) but rather of item form.

The jQuery expression:


sets the known value "Bob" to Sharepoint field of node with attribute 'Title="Name"', while the expression:

var ele = $("input[title='Name']").val();

gets that value into variable ele.
One more problem is that cited element doesn't contain any attribute Title?!

So, it is not clear to me what, from where to where the questioner is asking to set or to get? and what?

| improve this answer | |

Try this:
Using Sharepoint Designer 2010: modify form.
Wrap textbox by div with special ID.
Such as ID="myDiv"

This must help you to find needed textbox!

| 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.