FormValidator-object is undefined, when using TabComponent inside html-form

Hi,

I want to validate a html-form by using the FormValidator, however, when using a TabComponent inside the form, the FormValidator-object is always undefined when trying to validate() the form.

I've attached a demo that shows the error (when commenting the TabComponent code-lines, the example works fine...)

Any ideas?


Attachment: reactns2vzm_f8bf097d.zip

2 Replies

PM Ponmani Murugaiyan Syncfusion Team February 17, 2022 05:05 PM UTC

Hi Laurin, 

Currently we are checking your reported query, will update further details in 2 business days (February 21, 2022). 

Regards, 
Ponmani M 



PM Ponmani Murugaiyan Syncfusion Team February 21, 2022 01:42 PM UTC

Hi Laurin, 

We suggest you to define the formObject outside as like below code snippet to get the form instance when render inside the Tab component. 

For more information, refer the below documentation. 

let formObject; 
export const Default = () => { 
  const formId = 'form'; 
  React.useEffect(() => { 
    const formValidation = { 
      rules: { 
        description: { 
          required: [true, '* Enter a description'], 
        }, 
      }, 
    }; 
    formObject = new FormValidator(`#${formId}`, formValidation); 
  }, []); 
 
  const submit = (e) => { 
    if (formObject.validate()) console.log('Submit'); 
    else console.log('Submit error'); 
  }; 


Output: 

 

Regards, 
Ponmani M 


Loader.
Up arrow icon