function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
csrsakcsrsak 

Help Me writing the code in Visual force page

Hi,

 

I have a requirement in my application, requirement is like,

 

In one of the section of an object (example like 'LOAN' section), having two fields like A and B.

 

If a user enter some value into 'A' field, then the user must enter the value in 'B',

 

And if user enter value in 'B' field, then he must enter the value in 'A' field.

 

If the user not enter any data then the both fields should be empty.

 

 

Please help me, how to write the code to meet this requirement? Or can you please tell me any suggestion to fulfill this requirement?

 

Thanks in Advance,

 

 

Thanks and Regards,

 

Srinivas Chittela

 

 

 

 

bob_buzzardbob_buzzard

There are various ways you could achieve this, depending on whether you want to validate this client side, server side or at the point of writing to the database.

 

To validate client side, write some javascript that won't let the form be submitted unless the rules are met.

 

To validate server side, add the validation logic to the action method invoked when the form is submitted.

 

To validate at the point of writing to the database, add a validation rule.

 

If it were me, I'd be validating server side in the action method once the form is submitted.  Simply check the input fields are filled out as you expect - if they are  not, add an error to the page messages and return null to leave the user in the same view state.