The following information will guide you to ensure a prospect or customer completes required fields of your registration forms. There are two ways to validate that required fields are completed in a registration form:
- Client-side JavaScript that runs inside the visitor’s browser before the data is submitted to the server
- Server-side code that checks what field values have been sent and responds with an error page
Both solutions require simple HTML code to be installed for each form. When the form changes the code must be altered as well.
To avoid this issue we have developed a JavaScript library that allows you to enforce required fields in two easy steps with just some basic HTML knowledge.
- Just copy/paste one line to the HEAD section of your HTML file
- <HTML>
<HEAD>
<SCRIPT type=”text/javascript” src=”http://lfov.net/loopfuse-ext/required/required.js”></SCRIPT>
</HEAD>
- Troubleshooting : If your <HEAD> section has one or more existing <SCRIPT> tags, then add this line at the end as the last one.
- Add to any HTML form fields you wish to designate as required
- Example:
- before : <INPUT name=”email” id=”email”>
- after : <INPUT name=”email” id=”email” class=”required”>
- Troubleshooting : Does your form element already have a class attribute set? No problem.
- before : <INPUT name=”email” id=”email”>
- after : <INPUT name=”email” id=”email”line-height: 1.22em; cursor: default; color: rgb(255, 0, 0); “>required”>
Requirements : Make sure you have <LABEL> tags defined for each form field (by default we change their color to red when value is missing).
Limitations : The JavaScript currently supports INPUT, SELECT, TEXTAREA, and INPUT:RADIO fieldtypes. (no checkboxes)
Advanced Options :
- If you wish to override the default color of missing fields (red) set the “invalidColor” attribute on the FORM tag
- example : <FORM invalidColor=”blue” method=”post” action=”process.jsp”>
- By default, the labels of your required form fields will be prefixed (“before”) with an asterisk to indicate that the field is required. If you wish to override this behavior you can set the “asterisk” attribute on the FORM tag to indicate where the asterisk should be placed in relation to the label text.
- example : <FORM method=”post” action=”process.jsp” asterisk=”before”> (results in “*name”)
- example : <FORM method=”post” action=”process.jsp” asterisk=”after”> (results in “name*”)
- example : <FORM method=”post” action=”process.jsp” asterisk=”none”> (results in “name”)