Copy link to clipboard
Copied
Hello,
I'm putting in some javascript (still new to Javascript as well) on a new interactive pdf form that requires certain fields to be filled in. Currently, I've tested having this javascript code placed within the Validate > Run custom validation script and Calculate > Custom calculate script:
var fieldName = event.targetName
f = getField (event.target.name)
if (f.value.length == 0 || !f.value.replace(/\s/g, '').length){

f.setFocus()

app.alert(fieldName +" field is required. Please enter a value.")

}
Each has their own problem. Validate will only alert if something is entered in, if the user just tabs over or clicks in another field no alert is set off.
Calculate, will fire off each alert when one of them is triggered, which seems a bit annoying. Any suggestions to get this to work without trigger all the alert at once?
I'm open to other suggestions as well. Thanks!
Have something to add?