Skip to main content
Hi everyone,

I am very new to apex and just start to study how to add validation on the field. I am not able to do this from set up. In more detail I want to assign an id to apex:inputfield. I read a lot of information in the internet such as using partial id like http://www.kineticgrowth.com/javascript-visualforce-jquery-partial-id-selectors/

However know matter what I add in apex page, it doesn't show up inside the string. Here is my code:

<apex:pageBlock id="pageBlock" ...>

...

<apex:dataTable ...  id="transTableBrandPurchase" ">

...

<apex:inputField id="eric_test" value="{!varBla}" required="true" />

when I check the browser in html it gets

<input id="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id273" maxlength="255" name="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id273" size="20" type="text">

Based on Salesforce reference I should get id="j_xxx:j_yyy ...:pageBlock:transTableManufacturerPurchase:eric_test"

People may say that I can just use "pageBlock:transTableManufacturerPurchase", I cann't because in this page we display then rows and the other rows look like similar:

<input id="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id275" name="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id275" >

Right now I am working on validation in visualforce page with Jquery.

Any suggestion?

Thanks very much!

Eric

 
6 respuestas
  1. 11 may 2015, 04:13
    Hi Hargobind,

    Thanks for your point out that the difference between Text Field and InputField. It is very helpful!

    However I thought people still use it in InputFields, please search the tag "InputField" in these links.

    http://salesforce.stackexchange.com/questions/33754/how-to-get-ids-of-field-in-javascript-where-fields-are-displayed-through-apexr

    (

    <apex:inputField value="{!MyObject__c.MyField__c}" id="myInputField"/>

    )

    and 

    http://www.datixinc.com/define-default-value-lookup-field-salesforce-com/

    (

     <apex:inputField value="{!Quote__c.Order__c}" id="Order"/>

    )

    Eric
0/9000