You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ui/src/form/fields/EmailInputField.component.ts

29 lines
834 B

import {TextInputFieldComponent} from './TextInputField.component.js'
import {Component} from '../../decorators.js'
@Component('ex-input-email')
export class EmailInputFieldComponent extends TextInputFieldComponent {
public static validationRex = /^\s*[\w\-+_]+(\.[\w\-+_]+)*@[\w\-+_]+\.[\w\-+_]+(\.[\w\-+_]+)*\s*$/
protected static html = `
<label>
<span class="label"></span>
<input class="input" type="email">
<small class="error"></small>
</label>
`
validate(): boolean {
if ( !super.validate() ) {
return false
}
if ( !String(this.getValue()).match(EmailInputFieldComponent.validationRex) ) {
this.error = 'Value must be a valid e-mail address'
return false
}
return true
}
}