1

TEXT FIELD:

<apex:repeat value="{!TransTerms }" var="tms" id="repeatTag" rendered="{!showApproval && readOnly == false}">

  <div class="textinput" id="inner-div-tc">
 <apex:inputText value="{!tms.KAM_Remarks__c }" html-placeholder="Type here to add any remark/s." />

/* BUTTON

<span class="approvebtn">
 <apex:commandLink value="Submit for Approval" style="{!If(readOnly == true ,'pointer-events: none; background:#b7b7b7; color:#d7d7d7;','')}" styleClass="btn-normal-new" action="{!submitForApproval}" rendered="{!showApproval}"  onclick="approveValidate()" />
 </span>

*/

SCRIPT:

function approveValidate() {

var m = $(".textinput").val();
          if(m == ' ')
         {

event.preventDefault();
return false;
               }                           
else
 { return true;}

}
1
var m = $(".textinput").val();

the above will not be a valid statement as this will reference all the elems of that class...

instead you can reference a single instance of a dom element by its Id. this can be provided by using the below

var m=document.getelementbyid('{!$Component.repeatTag.**i**.input textID}').value;

where i is the iteration number for the repeat block starting from 0.

if the above throws an error, provide the Complete Id in the format

var m=document.getelementbyid('parentId:repeatTag:**i**:inoutTextboxId').value;

This way you can get the value of the input text box and then check if it has value, then proceed to submit action.

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.