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
Ravi23Ravi23 

command button click to show Apex page Messages and not to move below

   I have a page where there are 6 questions and out of them one functionality is if I select other there is a text box opening where I need to enter what the other is in that text box.

All 6 questions are mandatory.

The challenge or issue here is say I did not fill the first question but filled all other and come to the 5 question where I select other a text box opens and I enter some details and click next since I did not fill first question it will throw me a error as expected but the cursor is going back to the text box always instead of stopping at the top of the page. Can some one help me in resolving this.
Naval Sharma4Naval Sharma4
Hi Ravi,

You can use the following lines in code in your vf page.
 
<apex:outputPanel id="jsCode">
<script>
$(function(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
});
</script>
</apex:outputPanel>

put "jsCode" in your rerender property of comand button.

Let me know if you still need help.

Thanks,
Naval