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.

69 lines
1.7 KiB

4 years ago
$(document).ready( () => {
console.log('Load component - account')
const component = $('.component-account')
if(component.length) {
const pwdform = component.find('#pwdform')
const updatePassword = pwdform.find('.update-password')
const orders = component.find('.order-row')
orders.each( (i,e) => {
const order = $(e)
const id = order.data('id')
const toggle = order.find('.toggle')
const open = toggle.find('.open')
const close = toggle.find('.close')
const details = order.find('.order-details')
open.off('.click').on('click.click', (e) => {
open.hide(0)
close.show(0)
details.slideDown()
})
close.off('.click').on('click.click', (e) => {
open.show(0)
close.hide(0)
details.slideUp()
})
})
updatePassword.off('.click').on('click.click', (e) => {
checkForm()
})
const checkForm = () => {
console.log('checkForm')
const inputs = component.find('.input')
const passwords = component.find('.input[type="password"]')
let errors = 0
inputs.each( (i,e) => {
const input = $(e)
const type = input.prop('type')
const required = input.prop('required')
if(required) {
switch(type) {
case 'text':
case 'password':
if(!/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&^+-])[A-Za-z\d@$!%*#?&^+-]{8,}$/
.test(input.val())) {
input.addClass('error')
errors++
} else { input.removeClass('error') }
break;
}
}
})
if(!errors) {
pwdform.submit()
}
}
}
})