diff options
author | prashantsinalkar | 2017-01-24 11:07:47 +0530 |
---|---|---|
committer | prashantsinalkar | 2019-09-01 22:13:09 +0530 |
commit | 2007de8e1386121d536ce6d7b3d0ad328826f326 (patch) | |
tree | e0fc2da08d4c899e557461bbfba6ff94c06dd09a /js/textbook_companion_fixer.js | |
parent | 89ef9d359b29352e8c22ee8642cf203ae2f0c84b (diff) | |
download | r_tbc_fixer-2007de8e1386121d536ce6d7b3d0ad328826f326.tar.gz r_tbc_fixer-2007de8e1386121d536ce6d7b3d0ad328826f326.tar.bz2 r_tbc_fixer-2007de8e1386121d536ce6d7b3d0ad328826f326.zip |
aaded new validation for captions
Diffstat (limited to 'js/textbook_companion_fixer.js')
-rwxr-xr-x | js/textbook_companion_fixer.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/js/textbook_companion_fixer.js b/js/textbook_companion_fixer.js index d7b617e..b655b05 100755 --- a/js/textbook_companion_fixer.js +++ b/js/textbook_companion_fixer.js @@ -184,8 +184,18 @@ if (example_id != "0" && chapter_id != "0") { var caption = $caption.val(); caption = caption.trim(); + caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(caption) == true) { + alert('Enter valid text for example caption'); + return false; + } var chapter_caption = $("#edit-chapter-name").val(); - chapter_caption = chapter_caption.trim(); + chapter_caption = chapter_caption.trim(); + chapter_caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(chapter_caption) == true) { + alert('Enter valid text for chapter caption'); + return false; + } if (caption == '' || chapter_caption =='') { alert('Please enter new caption '); return false; @@ -216,6 +226,11 @@ if (example_id != "0") { var caption = $caption.val(); caption = caption.trim(); + caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(caption) == true) { + alert('Enter valid text'); + return false; + } if (caption == '') { alert('Please enter new caption '); return false; @@ -242,7 +257,12 @@ } else if ($('.chapter-caption-chk').prop('checked') == true) { if (chapter_id != "0") { var chapter_caption = $("#edit-chapter-name").val(); - chapter_caption = chapter_caption.trim(); + chapter_caption = chapter_caption.trim(); + chapter_caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(chapter_caption) == true) { + alert('Enter valid text for chapter caption'); + return false; + } if (chapter_caption == '') { alert('Please enter new caption '); return false; @@ -313,6 +333,10 @@ } }); }); + function validateCaption(text){ + var re = /([a-zA-Z|*|_|.|+|-|\\|?|/|!|~|!|@|#|$|%|^|&|(|)|<|>|{|}|;|:|\"|\'|,])\1{2,}/; + return re.test(text); + } /* toggle in edition */ $ind_ed = $(".ind-ed"); $ind_ed.click(function(e) { |