portal.mkgtu.ru/clientSide/packs/js/passport-data-validation.js

56 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2024-03-28 09:51:45 +03:00
window.seriesIsCorrect = seriesIsCorrect;
window.numberIsCorrect = numberIsCorrect;
/**
* @param {string} attribute
*
* @returns {string}
*/
function seriesIsCorrect(formName, modelId, attribute) {
return attributeIsCorrect(formName, modelId, attribute, 4);
}
/**
* @param {string} attribute
*
* @returns {string}
*/
function numberIsCorrect(formName, modelId, attribute) {
return attributeIsCorrect(formName, modelId, attribute, 6);
}
/**
* @param {string} attribute
* @param {int} charsLength
*
* @returns {string}
*/
function attributeIsCorrect(formName, modelId, attribute, charsLength) {
var docTypeField = $("#".concat(formName, "-document_type_id_").concat(modelId));
if (!docTypeField) {
return false;
}
var docType = docTypeField.val();
var attrValueField = $("#".concat(formName, "-").concat(attribute, "_").concat(modelId));
if (!attrValueField) {
return false;
}
var attrValue = attrValueField.val().replace(/[ _]/gm, "");
var docType = docTypeField.val();
if (
docType &&
attrValue &&
docType == documentTypePassportGuid &&
attrValue.length != charsLength
) {
return false;
}
return true;
}