You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -249,20 +253,39 @@ Input validation will run after user enters a value and go out from the input. I
249
253
</Story>
250
254
</Canvas>
251
255
252
-
Validation error messages are used from default browser error messages by default. If you want you can override error message by setting `invalid-text` attribute.
256
+
### Custom Error Text
257
+
258
+
Validation error messages are used from default browser error messages by default. If you want to override, you can do it in a native-like structure as below.
259
+
260
+
```html
261
+
<bl-inputid="input"required />
262
+
263
+
<script>
264
+
constblInput=document.getElementById("input");
265
+
blInput.addEventListener("bl-input", (e) => {
266
+
if(e.target.validity.valueMissing){
267
+
e.target.setCustomValidity("Custom Error Text");
268
+
}else{
269
+
e.target.setCustomValidity("");
270
+
}
271
+
});
272
+
</script>
273
+
```
274
+
275
+
### Custom Validation
276
+
277
+
If you want to use a different validation than all validations, you can do this with the `error` attribute. *Native validators will always be superior to custom errors.*
278
+
279
+
<bl-alerticonvariant="warning">When you use this attribute, the `dirty` prop will instantly become true.</bl-alert>
253
280
254
281
<Canvas>
255
-
<Storyname="Custom Error Message"
256
-
args={{ type: 'text', label: 'User Name', required: true, customInvalidText: 'This field is mandatory' }}
You can also set input validation as invalid by calling `forceCustomError()` method of the input. In this case input will be in invalid state and will report
263
-
its validity. Error message can be set with `invalid-text`. To clear this error state you would call `clearCustomError()` method. With the help of these 2 methods
264
-
you can run your custom validation logic outside of the basic validation rules we provide with validation attributes.
265
-
266
289
## Input Sizes
267
290
268
291
Inputs have 3 size options: `large`, `medium` and `small`. `medium` size is default and if you want to show a large or small input you can set `size` attribute.
@@ -227,6 +231,39 @@ Containing form submit also triggers validation. By default it uses browsers nat
227
231
</Story>
228
232
</Canvas>
229
233
234
+
### Custom Error Text
235
+
236
+
Validation error messages are used from default browser error messages by default. If you want to override, you can do it in a native-like structure as below.
If you want to use a different validation than all validations, you can do this with the `error` attribute. *Native validators will always be superior to custom errors.*
256
+
257
+
<bl-alerticonvariant="warning">When you use this attribute, the `dirty` prop will instantly become true.</bl-alert>
Textarea component uses [ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) to associate with it's parent form automatically.
0 commit comments