Copy link to clipboard
Copied
So I have a form with REQUIRED fields that cannot be left blank. Two fields in particular are important. What I'd like to have hapen is that if either of those fields is clicked/tapped/touched (and once they are active), it forces the user to input a valid entry before allowing them to move to the next or to another field. However, once a valid input is entered, they'll be free to advance to the next or another field.
Any suggestions?
By default the field is blank. The filed cannot be left blank either. So basically once the user enters that field, they need to complete it before moving on.
Copy link to clipboard
Copied
A validation script can be used to keep the field focus on the field until a valid value is entered.
Something like this
event.rc = ... Valid Value Test ...
if(!event.rc)
{
app.alert("You can enter but you can never leave").
event.target.setFocus();
}
Copy link to clipboard
Copied
Yes, I've gotten that far, however, the user can still skip or advance to another field. I was wondering is there was a way to keep the user locked into that field *until* a valid entry is provided. In other words, once the user selects the field they cannot click or tap on any other field until the field is correctly filled. The focus works great at zeroing out the field and returning the cursor to the beginning, but the user can simply bypass that field and move onto the next (which happens to also require a valid input before advancing).
Copy link to clipboard
Copied
It's not really a good idea to completely lock the user into a field. But there is a way to do it.
The Validate event is called when the field value changes. But the OnBlur event is called when the focus leaves the field. Use this a a second level detection to test for an empty field, since the validate is clearing the field.
if(event.target.value == "")
{
app.alert("You're not going anywhere").
event.target.setFocus();
}
Copy link to clipboard
Copied
Be careful not to get in a situation where a valid value is (say) 20 characters to type and the user gets an error for each of the 19 characters they type first! I've done that!!