You need to sign in to do that
Don't have an account?
honda57
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 />
<br/>
Button:
<input type="button" value="Begin Chat Session" id="prechat_submit" onclick="javascript: getRemoteContact();"/>
<!-- 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 />
<br/>
Button:
<input type="button" value="Begin Chat Session" id="prechat_submit" onclick="javascript: getRemoteContact();"/>
Validation Rules within Javascript Button please refer the below link for reference.
- https://salesforce.stackexchange.com/questions/56881/adding-a-validation-rule-to-a-javascript-button
- https://success.salesforce.com/answers?id=90630000000CjubAAC
Hope it will be helpful.Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.
Thanks
Rahul Kumar