Question: So it should work like that

squareDigits("a22b") on "a44b"

squareDigits("a9b2") on "a81b4"

What I have got so far :

```
public class Code {
    public static void main(String[] args) {
        String ok = "a2b9";
        System.out.println(squareDigits(ok)); // "a81b4"
    }

  public static String squareDigits(String s) {
        char[] pena = s.toCharArray();
        int aboba;
        for (char c : pena) {
            if (Character.isDigit(c)) {
                String s1 = Character.toString(c);
                int b = Integer.parseInt(s1);
                aboba = b * b;
                System.out.println(aboba);
            }
        }
        return "";
        }
    }

```

Im only beginner and this would very help me out

Answer: 
What was the original problem was assigning the `EditContext`. It was necessary to access it but it can be done via `editForm.EditContext` as in the example below.

Working example <https://blazorrepl.com/repl/Glkmbcbr323MP1VS55>

Parent component:

```
<ChildComponent @ref="myTestComponent" testModel="testModel" />
<input type="button" @onclick="buttonClick" value="validate programmatically" />
<div>@testMessage</div>

@code {
    TestModel testModel = new TestModel();
    ChildComponent myTestComponent;
    string testMessage;

    void buttonClick()
    {
        testMessage = "not passed validation";

        if (myTestComponent.CanSubmit())
        {
            testMessage = "passed validation!";
        }
    }
}

```

Child component:

```
@if(testModel != null) {
    <EditForm @ref="editForm" Model="@testModel">
        <input type="text" @bind="testModel.Name" />
        <DataAnnotationsValidator />
        <ValidationSummary />
    </EditForm>
}

@code {
    [Parameter]
    public TestModel testModel
    {
        get; set;
    }

    EditForm editForm;

    public bool CanSubmit()
    {
        return editForm.EditContext.Validate();
    }
}

```
I'll try to explain why your approach is not working and then suggest ways to solve it. I hope I understand your intentions correctly.

First you need to change the `<input type="text" ...>` to `<InputText @bind-Value="..." />`

When your method `buttonClick` is finished in your parent component, Blazor will call `StateHasChanged` on your component. It's part of the built-in logic of an `EventHandler`. This will trigger the component life cycle of your child component. During that cycle, the setter of your child component property `testModel` will be called, again. Blazor doesn't make any test for equality. (The only mighty check engine is the `DiffierentialRenderTree` at the end of a render cycle). That means a new `EditContext` will be created. This context, though, doesn't know about the validation error. Hence the message disappears. To prove that point, set a counter variable inside the setter and display it on the page. You will see this result.

[![enter image description here](https://i.stack.imgur.com/ZWpQ6.gif)](https://i.stack.imgur.com/ZWpQ6.gif).

To avoid this scenario, you create the `EditContext` once, when the parameters are set, for instance.

```
@code {

    [Parameter]
    public TestModel testModel { get; set; }

    EditContext editContext;

   protected override void OnParametersSet()
   {
       base.OnParametersSet();
       if(editContext == null)
       {
           editContext = new EditContext(testModel);
       }
   }

    public bool CanSubmit()
    {
        return editContext.Validate();
    }
}

```

If you need to update the model but preserve the validation state, write a comment, and we can go from there.

[![enter image description here](https://i.stack.imgur.com/12dpi.gif)](https://i.stack.imgur.com/12dpi.gif)