mirror of https://github.com/hykilpikonna/AquaDX
[+] Input validation
parent
c4e0717317
commit
eb45075414
|
@ -3,11 +3,14 @@
|
|||
export let value: string
|
||||
export let placeholder: string
|
||||
export let flex: number = 60
|
||||
|
||||
export let validate: (value: string) => boolean = () => true
|
||||
</script>
|
||||
|
||||
<div class="field" style="flex: {flex}">
|
||||
<label for={desc}>{desc}</label>
|
||||
<input type="text" placeholder={placeholder} bind:value={value} id="{desc}" on:change />
|
||||
<input type="text" placeholder={placeholder} bind:value={value} id="{desc}" on:change
|
||||
class:error={value && !validate(value)}/>
|
||||
</div>
|
||||
|
||||
<style lang="sass">
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
<!-- First input line -->
|
||||
<div class="inputs">
|
||||
<InputTextShort desc="Server Address" placeholder="e.g. http://aquadx.hydev.org"
|
||||
bind:value={src.server} on:change />
|
||||
bind:value={src.server} on:change validate={v => /^https?:\/\/[a-z0-9.-]+(:\d+)?$/i.test(v)} />
|
||||
<InputTextShort desc="Keychip ID" placeholder="e.g. A0299792458"
|
||||
bind:value={src.keychip} on:change />
|
||||
bind:value={src.keychip} on:change validate={v => /^[A-Z0-9]{11}$/.test(v)} />
|
||||
</div>
|
||||
|
||||
<!-- Second input line -->
|
||||
|
|
Loading…
Reference in New Issue