Created
July 30, 2020 04:00
-
-
Save ppazos/55b350b3a88ada78e1085a4ca6db3650 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
using the jquery serializedArray from a form is very difficult to validate the | |
data because of the structure, passing that to an object results in a easier | |
to use structure for data validation, this is an example on hwo that works | |
*/ | |
var params = $('#processed_form').serializeArray(); | |
var params_obj = {}; | |
$(params).each(function(i, field){ | |
params_obj[field.name] = field.value; | |
}); | |
if (params_obj.processed_status == 'accepted') | |
{ | |
if (!params_obj.check_number || !params_obj.check_date) | |
{ | |
// TODO: bootstrap alert inside the processed form | |
alert('The check number and date are required'); | |
return false; | |
} | |
} | |
else if (params_obj.processed_status == 'partial') | |
{ | |
if (!params_obj.check_number || !params_obj.check_date) | |
{ | |
// TODO: bootstrap alert inside the processed form | |
alert('The check number and date are required'); | |
return false; | |
} | |
if (!params_obj.total) | |
{ | |
// TODO: bootstrap alert inside the processed form | |
alert('The total $ is required'); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment