Created
May 8, 2015 12:34
-
-
Save Sarapulov/4082259e08c1fa90ef71 to your computer and use it in GitHub Desktop.
Example of ticket field and attachemnt 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