Ability to implement form validations

Good day, SyncFusion team!


We're currently using the PDF Viewer tool on a project running on ASP.NET Core to retrieve and submit PDF Forms. More recently, we wanted to implement validations within the PDF Forms being served, but found out that native validations created within the PDF don't work when submitting the form.


Additionally, we attempted to implement validations by enhancing the served documents' HTML fields and adding HTML5 functionalities like type="number" or type="date". Unfortunately, modifying the DOM would result on the affected fields to not be returned to the server upon submission.


Is there any feasible way that we might be able to implement validations within the PDF Forms being served so that the user won't be able to submit forms in invalid states?


Looking forward to your response.


1 Reply

DM Dhivyabharathi Mohan Syncfusion Team September 24, 2021 01:05 PM UTC

Hi Radames, 
 
 
We need to set the property EnableFormFieldsValidation as true to validate the form fields. We have an event ValidateFormFields to check whether all the fields are filled or not, before downloading the document. If any form field is non-fillable while downloading,  the validateFormFields event will gets triggered and non-fillable fields will be there in args.nonFillableFields from the event. If any fields are non-fillable, then the document will not be downloaded.  We have shared the code snippet and sample for your reference. 
 
 
<ejs-pdfviewer id="pdfviewer1" serviceUrl="/api/PdfViewer" documentPath="FormFillingDocument.pdf" enableFormFieldsValidation="true" validateFormFields="validateFormFields"></ejs-pdfviewer> 
 
 
function validateFormFields(args) { 
        var nonFillableFields = args.nonFillableFields; 
        console.log(nonFillableFields); 
    } 
 
 
 
 
 
 
Kindly try this and revert us, if you have any concerns. 
 
 
Regards, 
Dhivya. 


Loader.
Up arrow icon