mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 20:33:02 +00:00
docs(fluid-form): add example "Invalid state"
This commit is contained in:
parent
c9c172f88f
commit
a1bb1c2c63
2 changed files with 38 additions and 6 deletions
|
@ -1,19 +1,26 @@
|
||||||
<script>
|
<script>
|
||||||
import { FluidForm, FormGroup, TextInput, PasswordInput, Button,} from "carbon-components-svelte";
|
import {
|
||||||
|
FluidForm,
|
||||||
|
TextInput,
|
||||||
|
PasswordInput,
|
||||||
|
} from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
### Fluid form
|
### Fluid form
|
||||||
|
|
||||||
|
Note that the `inline` input variants cannot be used within a `FluidForm`.
|
||||||
|
|
||||||
<FluidForm>
|
<FluidForm>
|
||||||
<TextInput
|
<TextInput labelText="User name" placeholder="Enter user name..." required />
|
||||||
labelText="User name"
|
|
||||||
placeholder="Enter user name..."
|
|
||||||
required />
|
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
required
|
required
|
||||||
type="password"
|
type="password"
|
||||||
labelText="Password"
|
labelText="Password"
|
||||||
placeholder="Enter password..."
|
placeholder="Enter password..."
|
||||||
/>
|
/>
|
||||||
</FluidForm>
|
</FluidForm>
|
||||||
|
|
||||||
|
### Invalid state
|
||||||
|
|
||||||
|
<FileSource src="/framed/FluidForm/FluidFormInvalid" />
|
25
docs/src/pages/framed/FluidForm/FluidFormInvalid.svelte
Normal file
25
docs/src/pages/framed/FluidForm/FluidFormInvalid.svelte
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
FluidForm,
|
||||||
|
TextInput,
|
||||||
|
PasswordInput,
|
||||||
|
} from "carbon-components-svelte";
|
||||||
|
|
||||||
|
let password = "";
|
||||||
|
let invalid = false;
|
||||||
|
|
||||||
|
$: invalid = !/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,}$/.test(password);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<FluidForm>
|
||||||
|
<TextInput labelText="User name" placeholder="Enter user name..." required />
|
||||||
|
<PasswordInput
|
||||||
|
bind:value="{password}"
|
||||||
|
invalid="{invalid}"
|
||||||
|
invalidText="Your password must be at least 6 characters as well as contain at least one uppercase, one lowercase, and one number."
|
||||||
|
required
|
||||||
|
type="password"
|
||||||
|
labelText="Password"
|
||||||
|
placeholder="Enter password..."
|
||||||
|
/>
|
||||||
|
</FluidForm>
|
Loading…
Add table
Add a link
Reference in a new issue