Last active
August 29, 2015 14:20
-
-
Save Sarapulov/51ae8abdbf6023bdac55 to your computer and use it in GitHub Desktop.
Example of Help Center field and attachment validation
This file contains hidden or 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
// EXAMPLE OF FIELD VALIDATION | |
$('#request_custom_fields_23591935') | |
.focusout(function() | |
{ | |
var nameReg = /^[A-Za-z]+$/; | |
var isValid = $('#request_custom_fields_23591935') | |
.val() | |
.match(nameReg); | |
if (isValid && isValid.length > 0) | |
{ | |
console.log(' VALID! ') | |
$('input[type="submit"]') | |
.removeAttr('disabled'); | |
$('#request_custom_fields_23591935') | |
.css( | |
{ | |
"background-color": "lightgreen", | |
"border": "3px solid green" | |
}); | |
} | |
else | |
{ | |
console.log(' invalid! ') | |
$('input[type="submit"]') | |
.attr('disabled', 'disabled'); | |
$('#request_custom_fields_23591935') | |
.css( | |
{ | |
"background-color": "pink", | |
"border": "3px solid red" | |
}); | |
} | |
// EXAMPLE OF ATTACHEMNT VALIDATION | |
var isAttached = $('.upload-item') | |
.length; | |
if (isAttached > 0) | |
{ | |
console.log('HAS ATTACHMENT!'); | |
$('.upload-dropzone') | |
.css( | |
{ | |
"background-color": "lightgreen", | |
"border": "3px solid green" | |
}) | |
} | |
else | |
{ | |
console.log('NO ATTACHMENTS!'); | |
$('.upload-dropzone') | |
.css( | |
{ | |
"background-color": "pink", | |
"border": "3px solid red" | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// EXAMPLE OF ATTACHEMNT VALIDATION
function attachemntChecker () {
var isAttached = $('.upload-item')
.length;
if (isAttached > 0)
{
console.log('HAS ATTACHMENT!');
$('input[type=submit]').prop('disabled', false);
}