-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How we can validate the required fields? #33
Comments
Hello @jkyadav, Thanks for reaching out! Happy to assist you with this question. The first place I would reference is our guide here on how to iterate through all the fields in a PDF: https://www.pdftron.com/documentation/web/guides/forms/modify-fields/#iterate-over-all-fields And to check if all WebViewer(/* ... */).then(instance => {
const { documentViewer, annotationManager, Annotations } = instance.Core;
const checkIfAllRequiredFieldsAreFilled = (field) => {
const { value, type, widgets } = field;
if (type === 'Sig' && widgets[0].annot) {
// Logic for when a required Signature field has not been filled goes here
}
if (
field.flags.get(Annotations.WidgetFlags.REQUIRED)
&& (
// For Textboxes, Comboboxes, Listboxes
value === ''
// For Checkboxes or Radiobuttons
|| value === 'Off'
)
) {
// Logic for when a required field has not been filled goes here
}
// Check children fields
field.children.forEach(checkIfAllRequiredFieldsAreFilled);
}
documentViewer.addEventListener('annotationsLoaded', () => {
// Please ensure the annotationsLoaded event has fired before invoking the
// checkIfAllRequiredFieldsAreFilled method like below
const fieldManager = annotationManager.getFieldManager();
fieldManager.forEachField(checkIfAllRequiredFieldsAreFilled);
});
}); I hope this helps, but please feel free to let me know if you have any follow-up questions! |
@CorreyL Yes, it worked, thank you. |
I want to validate and make sure that end user filled in all the required fields upon clicking Complete button.
I could not find that code in your repo. could you put some light on this please?
![image](https://user-images.githubusercontent.com/6365791/160378073-cf3017d4-5f90-421a-9225-a0cceaa9a30d.png)
Thanks
The text was updated successfully, but these errors were encountered: