SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a form field:

<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Number_x0020_1" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Number_x0020_1')}"/>

I'd like to get the value of it in my javascript function. I was able to find it at the time of rending in html, but I know there's a better way to do this, but try as I might in the search I can't find it. Here's my solution right now.

var my_input1 = document.getElementById('ctl00_m_g_bb2353f3_193b_4566_86ff_0c4dd6671dfc_ff21_ctl00_ctl00_TextField').value;

I'm just using SharePoint Designer for this, and I don't want to adjust the web.config file to allow for server scripting if I can avoid it.

share|improve this question
up vote 4 down vote accepted

I guess the easiest way is to use jquery. You just have to refer jquery in your form from designer and then you can fetch the field from title or name attribute whichever is applicable.

I guess this is the input text field so your jquery will be like


You can see the title in developer toolbar from where you get the id.

Hope this helps. For more info refer

share|improve this answer
+1 That did it. I added jQuery to the page and this syntax worked. Thanks. – JArthur Sep 26 '13 at 14:03
Thanks that's brilliant, it worked for me too. – Niranjan Kulkarni Jul 8 '15 at 8:51

You could wrap the FormField in a span tag with an Id that you know and then you use querySelector to get the value (assuming you don't need to support below IE8).

<span id='myid'>
    <SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Number_x0020_1" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Number_x0020_1')}"/>

var my_input1 = document.querySelector("span#myid input").value;

At least this way you wouldn't be relying on the .NET generated ID.

share|improve this answer

I don't know if you are trying to alter an existing lists' Form page or having your own, but you can get ClientID in the aspx page by using the example below. However I'm not sure how handles IDs using special characters.

var my_input1 = document.getElementById("<%= ff2{$Pos}.ClientID%>");
share|improve this answer

Similar question to yours has already been answered on StackOverflow: Javascript to get sharepoint form field value to a variable.

You have to append "Field" to the field name; e.g. for Title (using jQuery):

var $titleField = $('input[id*=TitleField]');
share|improve this answer
Don't forget you can flag posts as duplicates, although in this case it is on SO. – SPDoctor Sep 26 '13 at 7:49
$("select[title*='Time Period'] option:selected").text();
share|improve this answer
Can you please also provide some explanation of the code. – Asad Refai Apr 21 at 9:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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