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

How can I add field validation rules into my button script?

I am building a customer facing VF page with several input fields (this is being used as a Pre-Chat form in Live Agent).  I need to run validation rules to ensure these fields are populated when the "begin" button is clicked.  How do I do this?  Adding required="true" to the input fields themselves doesn't do anything.

<!-- Detail inputs -->
First Name: <input type="text" name="liveagent.prechat:leadFirstName" onchange="javascript: document.getElementById('prechat_field').value=this.value;" required="true"/><br />
Last Name: <input type="text" name="liveagent.prechat:leadLastName"  required="true"/><br />
Company: <input type="text" name="liveagent.prechat:leadCompany"  required="true"/><br />
Email: <input type="text" id="contactEmail" name="liveagent.prechat:leadEmail" required="true"/><br />
Phone: <input type="text" name="liveagent.prechat:leadPhone"/><br />

<input type="button" value="Begin Chat Session" id="prechat_submit" onclick="javascript: getRemoteContact();"/>
Rahul KumarRahul Kumar (Salesforce Developers) 

Validation Rules within Javascript Button please refer the below link for reference. Hope it will be helpful.

Please mark it as best answer if the information is that question is removed from an unanswered question and appear as a proper solution.

Rahul Kumar