0

i have created a custom edit form in sharepoint designer and i would like to add placeholder hint text to a text field if it is possible. basically i have 2 fields; "Document_Type" and "Document_Name. Document_Type is a dropdown field with 3 values; Training,Technical evaluation and Exam. What i would like to do is use jquery to add placeholder hint text to the Document_Name field based on what option is selected in the Document_Type field.

If Training is selected display "enter training number" in the Document_Name field , if Technical evaluation is selected display "enter technical evaluation number" in the Document_name field and if Exam is selected display " enter exam number". below is the code for the 2 fields as it is shown is sharepoint designer

<tr>
                    <td width="190px" valign="top" class="ms-formlabel">
                        <H3 class="ms-standardheader">
                            <nobr>Document_Type</nobr>
                        </H3>
                    </td>
                    <td width="400px" valign="top" class="ms-formbody">
                        <SharePoint:FormField runat="server" id="ff5{$Pos}"  ControlMode="Edit" FieldName="Document_Type" __designer:bind="{ddwrt:DataBind('u',concat('ff5',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Document_Type')}"/>
                        <SharePoint:FieldDescription runat="server" id="ff5description{$Pos}" FieldName="Document_Type" ControlMode="Edit"/>
                    </td>
                </tr>
                <tr class="docnameclass">
                    <td width="190px" valign="top" class="ms-formlabel">
                        <H3 class="ms-standardheader">
                            <nobr>Document_Name</nobr>
                        </H3>
                    </td>
                    <td width="400px" valign="top" class="ms-formbody">
                        <SharePoint:FormField runat="server" id="ff6{$Pos}" ControlMode="Edit" FieldName="Document_Name" __designer:bind="{ddwrt:DataBind('u',concat('ff6',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Document_Name')}"/>
                        <SharePoint:FieldDescription runat="server" id="ff6description{$Pos}" FieldName="Document_Name" ControlMode="Edit"/>
                    </td>

                </tr>

I use the code below to check the the value selected for Document_Type and show what i would like to achieve with the comments.

$(document).ready(function() {
var docType = $("select[title='Document_Type']").val();
if(docType == "Training"){
// --- do this -> add placeholder text to Document_Name field "enter training number"
}else if(docType == "Technical evaluation"){
// --- do this -> add placeholder text to Document_Name field "enter technical evalution number"
}else if(docType == "Exam"){
// --- do this -> add placeholder text to Document_Name field "enter exam number"
}
}

Any Help would be much appreciated.

  • You can use XSLT conditions like if/else. w3schools.com/xml/ref_xsl_el_if.asp – Christoffer Mar 6 '17 at 10:21
  • Hi Christopher, any examples of how i would implement that using sharepoint designer ? – derek Mar 6 '17 at 10:57
  • Just add some XSLT Code to check the value of the field, and then add a paragraph or text value. (sorry, was really long ago that i did something similar). stackoverflow.com/questions/13622338/… – Christoffer Mar 6 '17 at 11:29
  • cant seem to get anything working using xslt , i think i will just use html hearder tags <h3 class="showthisheader"> tags and then use jquery to show or hide the headers based on the selected dropdown option. if(docType == "Training"){ $('h3.showthisheader').show(); – derek Mar 6 '17 at 15:52

Your Answer

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

Browse other questions tagged or ask your own question.