[SalesForce] On a Live Agent Pre Chat form, how can I make a field mandatory

I have a pre-chat page and it's working fine. I just need to make (say) the name field a required one. HTML 5 states you can use a "required" attribute on the <input type="text" ... >
But Salesforce won't let me save that.

Is it really down to JavaScript to validate the form?

Update to show code as is

<apex:page docType="html-5.0" showHeader="false" sidebar="false"
    standardStyleSheets="false" >
....
....
<input type='text' name='liveagent.prechat:ContactName' id='ContactName' placeholder='Contact name' required='true' />
....
....
<input type="submit" name="submit" class="submit" value="Submit" id='prechat_submit'/>

I'm wondering if there's something in there that shouldn't be – or formatting could be interfering, but I can't see how it would.

Best Answer

You do not need to use javascript to ensure field requirements. This is a simple HTML attribute you can add to each field element. Add the following attribute to each field that needs to be required:

required="true"

First name:

<input required="true" type='text' name='liveagent.prechat:User_FirstName' id='customField1' /><br />