mirror of
https://github.com/comatory/fb2iCal
synced 2025-02-17 12:10:36 +01:00
fix: validate input on submit
This commit is contained in:
parent
2d195fd48c
commit
37d931f6ce
@ -28,6 +28,7 @@
|
|||||||
export let pending
|
export let pending
|
||||||
|
|
||||||
let value
|
let value
|
||||||
|
let form
|
||||||
|
|
||||||
const onChange = (e) => {
|
const onChange = (e) => {
|
||||||
value = e.currentTarget.value
|
value = e.currentTarget.value
|
||||||
@ -41,12 +42,16 @@
|
|||||||
console.log(inputClasses)
|
console.log(inputClasses)
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
|
if (!form.reportValidity()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
createEvent(value, { logger })
|
createEvent(value, { logger })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form id="form">
|
<form id="form" bind:this={form}>
|
||||||
<input
|
<input
|
||||||
required
|
required
|
||||||
pattern="^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?|\d+$"
|
pattern="^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?|\d+$"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user