summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2017-01-24 11:07:47 +0530
committerprashantsinalkar2017-01-24 11:07:47 +0530
commitccad5925edd8bf1821e53411f0644a00abd2331a (patch)
tree86310d474a5be9de91fa95fa3b88b6e2dd1109c1
parent3fba4bb9b289f37c246588683413b6eb9e5b5d15 (diff)
downloadtextbook_companion_fixer-ccad5925edd8bf1821e53411f0644a00abd2331a.tar.gz
textbook_companion_fixer-ccad5925edd8bf1821e53411f0644a00abd2331a.tar.bz2
textbook_companion_fixer-ccad5925edd8bf1821e53411f0644a00abd2331a.zip
aaded new validation for captions
-rwxr-xr-xjs/textbook_companion_fixer.js28
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) {