+ Start a Discussion
rajesh_yrajesh_y 

javascript in visualforce

hi dear

  how can i trap inputtext value in javascript

  if i want to check validations on inputtext by  using javascript

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

Find below a sample code to check and validate the inputtext in Apexinputtext and html inputtext:

 

                <apex:page />

                                <apex:form>

                                                <apex:inputtext value="{!propTextdata}" />

                                                <input value="VKS"/>

 

                                                <input value="Click Me" onclick="Validt();" />

 

                                                <script>

                                                                function Validt()

                                                                {             

                                                                                var ApexData = document.getElementById('{!$Component.PageId:FormId:ApexTextId}').value;

                                                                                var HtmlData = document.getElementById('HtmlTextId').value;

                                                                                ApexData   // will contain the value of Apex inputtext

                                                                                HtmlData   // will contain the value of HTml inputtext

                                                                }

                                                </script>

                                <apex:form

                </apex:page>

All Answers

aalbertaalbert

Check out the Visualforce docs , it has a section specifically on using JS in Visualforce. Link

Pradeep_NavatarPradeep_Navatar

Find below a sample code to check and validate the inputtext in Apexinputtext and html inputtext:

 

                <apex:page />

                                <apex:form>

                                                <apex:inputtext value="{!propTextdata}" />

                                                <input value="VKS"/>

 

                                                <input value="Click Me" onclick="Validt();" />

 

                                                <script>

                                                                function Validt()

                                                                {             

                                                                                var ApexData = document.getElementById('{!$Component.PageId:FormId:ApexTextId}').value;

                                                                                var HtmlData = document.getElementById('HtmlTextId').value;

                                                                                ApexData   // will contain the value of Apex inputtext

                                                                                HtmlData   // will contain the value of HTml inputtext

                                                                }

                                                </script>

                                <apex:form

                </apex:page>

This was selected as the best answer
rajesh_yrajesh_y

thank you very much