Question: I want to render some JSX based on a condition, but it is not happenning. Below is my code -

```
chkAccess().then((result) => {
    console.log(result)
    if(result) {
        alert("Access Granted")
        return (
            <div className='login_container p-5 m-5 bg-dark'>
            <h1 className='text-center p-3'>You are seeing this page because you are a Manager</h1>
            </div>
        )
    }
    alert("Access Denied")
    return(<Access_denied />)

```

The JSX returned is not getting rendered. Why is it so and how I can i fix it?

I expect the returned code to be rendered, but It did not happen.

Answer: 
> 
> If the user disables JavaScript in the browser, is server-side validation also performed by OnValidSubmit?
> 
> 
> 

Yes, as long as no `OnSubmit` handler is registered on `EditForm`.
Here's the relevant code from `EditForm`

```cs
    private async Task HandleSubmitAsync()
    {
        Debug.Assert(_editContext != null);

        if (OnSubmit.HasDelegate)
        {
            // When using OnSubmit, the developer takes control of the validation lifecycle
            await OnSubmit.InvokeAsync(_editContext);
        }
        else
        {
            // Otherwise, the system implicitly runs validation on form submission
            var isValid = _editContext.Validate(); // This will likely become ValidateAsync later

            if (isValid && OnValidSubmit.HasDelegate)
            {
                await OnValidSubmit.InvokeAsync(_editContext);
            }

            if (!isValid && OnInvalidSubmit.HasDelegate)
            {
                await OnInvalidSubmit.InvokeAsync(_editContext);
            }
        }
    }

```

In Blazor Server everything happens in the Hub Session on the server. In WASM it all happens in the WASM code running in the Browser.

`EditForm` has an `EditContext` instance (either passed to it directly or created from `Model`) which it cascades.

`Editcontext` has a `ValidationMessageStore` that maintains a list of valid messages.

`EditContext` has a `Validate` method that raises it's `OnValidationRequested` event. It doesn't do any validation itself.

Any validators with a registered handler get called, run their validation processes and log any messages to the central message store.

In the code below (taken from MS-Docs) `DataAnnotationsValidator` captures the cascaded `EditContext` from `EditForm` and registers a handler. When triggered it does it's business with the model attributes and logs any validation messages to the message store.

```
<EditForm Model="@starship" OnValidSubmit="@HandleValidSubmit">
    <DataAnnotationsValidator />

```

Consumer components, such as `ValidationSummary` capture the cascaded `EditContext` and read messages from the message store.

Input controls do the same thing to toggle their css based on state of their field.

All these consumers use the expression supplied in the `For` parameter to find the messages specify to the field supplied in the `For` expression.
You can trigger the validation by yourself. This works in Blazor Server like this:

```
<EditForm Model="YourModel" @ref="_form">
    @* Your Form here *@
</EditForm>

<button type="button" class="btn btn-primary" @onclick="SubmitAsync">Submit</button>

@code {

    private EditForm? _form;

    private Task SubmitAsync()
    {
        if(_form is null || _form.EditContext is null)
        {
            return Task.CompletedTask;
        }

        if (_form.EditContext.Validate())
        {
            // Do your stuff here.
        }
    }
}

```

Keep in mind though, with this approach it is no longer possible to submit the form by pressing Enter.