Form Validation

Hello Everyone,

I am using  sfTextBox in Blazor server application and have implemented form validations. 

But validation is not working properly.

As soon as a control loses focus validation is triggered instead of before submitting the form.


I have included in the attachment relevant snippet of my code


Thank

Attachment: file_8140716c.rar

3 Replies 1 reply marked as answer

BC Berly Christopher Syncfusion Team May 7, 2021 01:23 PM UTC

Hi Paul, 
  
Greetings from Syncfusion support. 
  
We have checked the shared code snippet and screenshot. The reported issue is occurred due to call the validate method(disabled=”context.Validate()”) for the disabled attribute in the button element. When you modify the form element, the whole form element will be validated due to this expression. So, we suggest you to update the disabled attribute in the valid and invalid submit action handler to get rid of the reported issue. 
  
<input tabindex="21" type="submit" disabled="@isDisabled" class="form-control col-1 btn btn-primary " value="Save" /> 
@code{ 
public bool isDisabled { get; set; } = false; 
  protected async Task SavePatient() // valid submit action 
    { 
        isDisabled = false; 
    } 
    public void InvalidSubmit() // invalid submit action 
    { 
        isDisabled = true; 
    } 
} 
 
  
Please find the sample from the below link. 
  
Regards, 
Berly B.C 


Marked as answer

PA Paul May 19, 2021 01:32 AM UTC

Hello Berly,

Thanks for your help.

Your suggestion worked, I am indeed grateful


Regards,

Paul A


BC Berly Christopher Syncfusion Team May 19, 2021 04:35 AM UTC

Hi Paul, 
  
We are glad to know that the issue is resolved at your end. Please let us know if you need further assistance on this. 
  
Regards, 
Berly B.C 


Loader.
Up arrow icon