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.
31 lines
870 B
31 lines
870 B
2 years ago
|
import * as riot from 'riot'
|
||
|
|
||
2 years ago
|
import FormValidator from './formValidator'
|
||
2 years ago
|
import FieldError from './fieldError.riot'
|
||
2 years ago
|
import FormComponent from './formComponent.riot'
|
||
2 years ago
|
|
||
|
// register & mount riot component
|
||
|
riot.register('field-error', FieldError)
|
||
|
riot.mount('field-error')
|
||
|
|
||
|
// creating formValidation
|
||
2 years ago
|
const formValidation = new FormValidator(document.querySelector('.form-html'), {
|
||
2 years ago
|
'email': {
|
||
|
'presence': true,
|
||
|
'email': true
|
||
|
},
|
||
|
'password': {
|
||
|
'presence': true
|
||
|
}
|
||
2 years ago
|
}, true)
|
||
|
|
||
|
formValidation.onSuccess((event, data) => {
|
||
2 years ago
|
event.preventDefault()
|
||
|
|
||
|
// show message and content of data from form
|
||
|
document.querySelector('#result .content').innerHTML = '<p>' + JSON.stringify(data) + '</p>'
|
||
|
document.querySelector('#result').classList.remove('hidden')
|
||
2 years ago
|
})
|
||
|
|
||
|
riot.register('form-component', FormComponent)
|
||
|
riot.mount('form-component')
|