Settings form validation reworked

pull/72/head
morpheus65535 7 years ago
parent 05a7edbbfb
commit f083807ef6

@ -801,30 +801,84 @@
$('#settings_form')
.form({
fields: {
settings_general_ip : ['regExp[/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/]', 'empty'],
settings_general_port : ['integer[1..65535]', 'empty'],
settings_sonarr_ip : ['empty'],
settings_sonarr_port : ['integer[1..65535]', 'empty'],
settings_sonarr_apikey : ['exactLength[32]', 'empty'],
settings_subliminal_providers : ['minCount[1]', 'empty'],
settings_subliminal_languages : ['minCount[1]', 'empty']
settings_general_ip : {
rules : [
{
type : 'regExp[/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/]'
},
{
type : 'empty'
}
]
},
settings_general_port : {
rules : [
{
type : 'integer[1..65535]'
},
{
type : 'empty'
}
]
},
settings_sonarr_ip : {
rules : [
{
type : 'empty'
}
]
},
settings_sonarr_port : {
rules : [
{
type : 'integer[1..65535]'
},
{
type : 'empty'
}
]
},
settings_sonarr_apikey : {
rules : [
{
type : 'exactLength[32]'
},
{
type : 'empty'
}
]
},
settings_subliminal_providers : {
rules : [
{
type : 'minCount[1]'
},
{
type : 'empty'
}
]
},
settings_subliminal_languages : {
rules : [
{
type : 'minCount[1]'
},
{
type : 'empty'
}
]
}
},
inline : true,
on : 'blur',
onValid: function(){
$('#form_validation_error').hide();
$('.submit').removeClass('disabled');
},
onInvalid: function(){
onFailure: function(){
$('#form_validation_error').show();
$('.submit').addClass('disabled');
},
onFailure: function(){
return false;
},
onSuccess: function(){
$('#form_validation_error').hide();
$('.submit').removeClass('disabled');
$('#loader').addClass('active');
}
})

Loading…
Cancel
Save