Setting a form field to “Required” in the “General Properties” tab forces the user to fill in the selected form field. But there are cases when you need the user to fill out a particular field before moving on to the rest of the form. You could use JavaScript to dynamically enable or disable parts of the form but that can be cumbersome to keep track of. The ideal situation would be to, where appropriate, force the user to enter data into a required field before moving to another field.
Add the following code to the “On Blur” action of the field you want to be required.
Add the following code to the "On Blur" action of the field you want to be required.
f = getField(event.target.name)
if (f.value.length == 0)
{
f.setFocus()
//Optional Message - Comment out the next line to remove
app.alert("This field is required. Please enter a value.")
}
This code will be triggered when the user tries to either tab out of the field or uses the mouse to click into another field. It tests to see if the length of the contents of the field is 0 (an empty field) and then places the cursor back in the field if it is. If the length of the contents is greater than 0 (a field value has been entered) the script does nothing and the user can move on.
You can download a PDF file of this tip that includes example fields here.
+