• Matt Virgilio
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I am trying to make a set of text fields in a form required in a VisualForce page. I was told to use Javascript for this, specifically the checkField function but I am not sure how this is structured. Below is my form. Thank you everyone!





<apex:page showheader="false" >
<html>
<head>
<script type="text/javascript">
(function() {
function handlePageLoad() {
var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
document.getElementById('prechatForm').setAttribute('action',
decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
}
if (window.addEventListener) {
window.addEventListener('load', handlePageLoad, false);
} else {
window.attachEvent('onload', handlePageLoad, false);
}
})();
   
</script>
</head>
<body>
<form method="post" id="prechatForm">

<!-- Detail inputs -->
First Name: <input type="text" name="liveagent.prechat:First Name" id="First_Name__c" /><br /><br />
Last Name: <input type="text" name="liveagent.prechat:Last Name" /><br /><br />
Dealership Name: <input type="text" name="liveagent.prechat:Dealership Name" /><br /><br />


<input type="submit" value="Request Chat" id="prechat_submit" />

</form>
</body>
</html>
</apex:page>
Here is the code to a Live Agent pre-chat form I am using, but I can't route the text values back to my custom fields. My development skills are very minimal, so apologies if this is a no-brainer!

<body>
<form method="post" id="prechatForm">

<!-- Detail inputs -->
First Name: <input type="text" name="liveagent.prechat:First Name"  /><br /><br />
Last Name: <input type="text" name="liveagent.prechat:Last Name" /><br /><br />
Dealership Name: <input type="text" name="liveagent.prechat:Dealership Name" /><br /><br />

<input type="submit" value="Request Chat" id="prechat_submit" />

</form>
</body>

Thanks all!