generated from lucien/api-template
fix: added message errors to user and channel creation
This commit is contained in:
parent
649c43da98
commit
1656e95557
3 changed files with 20 additions and 4 deletions
|
@ -31,6 +31,11 @@ export default function CreateChannel() {
|
|||
<Link to="/">Home</Link>
|
||||
<h1>Create Channel</h1>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<p>
|
||||
{!/^[a-zA-Z0-9-_]+$/.test(name) && name.length != 0 && (
|
||||
<span>Channel name can only contain letters, numbers, - and _</span>
|
||||
)}
|
||||
</p>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Name"
|
||||
|
@ -43,7 +48,9 @@ export default function CreateChannel() {
|
|||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
/>
|
||||
<button type="submit">Create</button>
|
||||
<button type="submit" disabled={!/^[a-zA-Z0-9-_]+$/.test(name)}>
|
||||
Create
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -32,6 +32,11 @@ export default function Register () {
|
|||
<Link to="/">Home</Link>
|
||||
<h1>Register</h1>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<p>
|
||||
{!/^[a-zA-Z0-9-_]+$/.test(username) && username.length != 0 && (
|
||||
<span>Username can only contain letters, numbers, - and _</span>
|
||||
)}
|
||||
</p>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
|
@ -44,7 +49,9 @@ export default function Register () {
|
|||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
<button type="submit">Register</button>
|
||||
<button type="submit" disabled={!/^[a-zA-Z0-9-_]+$/.test(username)}>
|
||||
Register
|
||||
</button>
|
||||
</form>
|
||||
<Link to="/login">Login</Link>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue