diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json
index a509163e7e262c7ecd05453157b35154e37df73e..cacda7f063f485577aa6c9f2a346f206c2913e24 100644
--- a/src/BootstrapBlazor.Shared/Locales/en.json
+++ b/src/BootstrapBlazor.Shared/Locales/en.json
@@ -1172,6 +1172,8 @@
"P7": "The BootstrapInput component binds byte[] array and formats it as an example of base64 encoded string",
"Block11Title": "The password box",
"Block11Intro": "Use the BootstrapPassword component",
+ "IsTrimTitle": "Trim",
+ "IsTrimIntro": "Use IsTrim=\"true\" to automatically trim white space when entering content",
"PlaceHolder": "Please enter ...",
"TestName": "Tom",
"Log": "The key triggers the current text box value",
diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json
index 2bbb17590b963101b338991f1515e07d3c0e35a2..c0323460bc54c4e6b1a42a520ce09c80ec3c0543 100644
--- a/src/BootstrapBlazor.Shared/Locales/zh.json
+++ b/src/BootstrapBlazor.Shared/Locales/zh.json
@@ -1172,8 +1172,8 @@
"P7": "BootstrapInput 组件绑定 byte[] 数组,格式化成 base64 编码字符串示例",
"Block11Title": "密码框",
"Block11Intro": "使用 BootstrapPassword 组件",
- "Block12Title": "修剪空白",
- "Block12Intro": "使用 IsTrim=\"true\" 可在输入内容的时候自动修剪空白",
+ "IsTrimTitle": "修剪空白",
+ "IsTrimIntro": "使用 IsTrim=\"true\" 可在输入内容的时候自动修剪空白",
"PlaceHolder": "请输入 ...",
"TestName": "张三",
"Log": "按键触发 当前文本框值",
diff --git a/src/BootstrapBlazor.Shared/Samples/Inputs.razor b/src/BootstrapBlazor.Shared/Samples/Inputs.razor
index 1434b69af91664d6352678b9a1e6009bbc493266..3f602dfec2c3c523961ec7b038bd5ff963574ef0 100644
--- a/src/BootstrapBlazor.Shared/Samples/Inputs.razor
+++ b/src/BootstrapBlazor.Shared/Samples/Inputs.razor
@@ -150,13 +150,15 @@
-
+
+
@Localizer["Span1"]
-
+
+ 123@Model.Name456
diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.js b/src/BootstrapBlazor/Components/Input/BootstrapInput.js
index 2d781a86d39a86108e794c3f4f6ea73594c0fc6c..e0ec1de2e8cd20c06597b4196d20b95500a58f42 100644
--- a/src/BootstrapBlazor/Components/Input/BootstrapInput.js
+++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.js
@@ -16,12 +16,6 @@
$el.on('focus', function () {
$(this).select();
});
- },
- bb_input_trim: function (el) {
- var $el = $(el);
- $el.on('change', function () {
- $(this).val($(this).val().trim());
- });
}
});
})(jQuery);
diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs
index 700b1d9baa74d7eec3155ce85a6ae98cc0ff5672..e51baae1c1ffa701b5b148c40d2243564d86463c 100644
--- a/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs
+++ b/src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs
@@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
namespace BootstrapBlazor.Components
@@ -145,10 +146,6 @@ namespace BootstrapBlazor.Components
{
await JSRuntime.InvokeVoidAsync(FocusElement, "bb_input_selectAll");
}
- if (IsTrim)
- {
- await JSRuntime.InvokeVoidAsync(FocusElement, "bb_input_trim");
- }
}
}
@@ -163,6 +160,15 @@ namespace BootstrapBlazor.Components
? Utility.Format(value, FormatString)
: base.FormatValueAsString(value));
+ ///
+ /// TryParseValueFromString
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override bool TryParseValueFromString(string value, [MaybeNullWhen(false)] out TValue result, out string? validationErrorMessage) => base.TryParseValueFromString(IsTrim ? value.Trim() : value, out result, out validationErrorMessage);
+
///
///
///