mirror of
https://github.com/myvesta/vesta
synced 2025-07-15 01:23:23 -07:00
Field length validation
This commit is contained in:
parent
eb2e896a8e
commit
6ceecb886e
2 changed files with 40 additions and 0 deletions
|
@ -30,6 +30,9 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() == '' || $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
|
@ -38,6 +41,9 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() == '') {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
|
@ -45,6 +51,9 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'required' : function(elm) {
|
||||
|
@ -69,18 +78,25 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' must contain only letters without spaces or other symbols'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'email': function(elm) {
|
||||
if ($(elm).val().search(/^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/) == -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid email'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'ip': function(elm) {
|
||||
if ($(elm).val().trim() != '' && (/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/).test($(elm).val()) == false) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid IP value'};
|
||||
}
|
||||
|
||||
return {VALID: true};
|
||||
},
|
||||
'domain': function(elm) {
|
||||
|
@ -93,12 +109,18 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && (/^([a-z0-9\.])*[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/).test($(elm).val()) == false) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid NS name'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'cronminute': function(elm) {
|
||||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong minute value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.MINUTE_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'cronhour': function(elm) {
|
||||
|
@ -108,6 +130,9 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong hour value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.HOURS_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'cronwday': function(elm) {
|
||||
|
@ -117,6 +142,9 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^123456\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong week day value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.WDAY_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'cronmonth': function(elm) {
|
||||
|
@ -126,6 +154,9 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong month value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.MONTH_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'cronday': function(elm) {
|
||||
|
@ -135,6 +166,9 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong day value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.DAY_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue