FormItem Field doesn't allow spaces
2 Answers 23 Views
Noah
Top achievements
Rank 1
Noah asked on 14 Jul 2021, 01:25 AM | edited on 16 Jul 2021, 03:36 PM

I'm working on a task where the user needs to be able to enter a space in the form field. I have attached an example of the setup code I am currently using. When the user attempts to add a space in the textbox it is simply not accepted and nothing happens. I have been researching this issue and have not found much help available. So my question are: Is there a workaround? Should I be taking a different approach? 

public string CustomerName
{
    get { get return Ship.CustomerName ?? ""; }
    set { Ship.CustomerName = value; }
}

<FormItems>
    <FormItem Field="@nameof(Example.CustomerName)"/>
</FormItem>

Update:

While troubleshooting this issue I learned a couple of things. My input fields were placed inside of the Telerik Panel Bar. This panel bar is preventing / not registering spaces. I looked through the documentation to see if this was intentional and have not found anything. Has anyone encountered any similar issues? If so, what did you use as a workaround? 

Documentation: https://docs.telerik.com/blazor-ui/components/panelbar/events

Matthias
Top achievements
Rank 3
Iron
Iron
Iron
commented on 14 Jul 2021, 09:20 AM

Hi Noah - I am in the process of adding input to some windows where spaces also need to be added. But have no problem:


<TelerikForm Model="@_Customer"
OnValidSubmit="@HandleValidSubmit"
OnInvalidSubmit="@HandleInvalidSubmit">
<FormItems>
<FormItem Field="@nameof(Customer.Name)"></FormItem>
<FormItem Field="@nameof(Customer.City)"></FormItem>
</FormItems>
</TelerikForm>

<code>
@Result
</code>


@code {
public Customer _Customer { get; set; } = new Customer();
public bool ValidSubmit { get; set; } = false;
public string Result { get; set; } = string.Empty;
async Task HandleValidSubmit()
{
ValidSubmit = true;
Result = $"{_Customer.Name} {_Customer.City} len{_Customer.Name.Length}";
await InvokeAsync(StateHasChanged);
}

void HandleInvalidSubmit()
{
ValidSubmit = false;

}

public class Customer
{
public string Name { get; set; }
public string City { get; set; }
}

}
Have a look at the attachment - is counting also spaces - sorry is not possible (only as an answer) Post the picture as an answer in a few seconds

2 Answers, 1 is accepted

Sort by
0
Matthias
Top achievements
Rank 3
Iron
Iron
Iron
answered on 14 Jul 2021, 09:22 AM

The "Name" field has the length 1 (space) you can see in len: 1

Hope this helps you a little bit - I think the problem is somewhere else

0
Radko
Telerik team
answered on 14 Jul 2021, 01:31 PM

Hello Noah,

I can confirm the FormItem does allow the input of empty spaces as shown on our demos.

As a next step, you can open a new support ticket where you can send us a runnable demo application where the issue is reproducible and we can further investigate the issue. 

Regards, Radko Stanev Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Asked by
Noah
Top achievements
Rank 1
Answers by
Matthias
Top achievements
Rank 3
Iron
Iron
Iron
Radko
Telerik team
Share this question
or