Created
August 12, 2021 14:27
-
-
Save cygeorgel/61e98162771a6efbef9d7ee22d510198 to your computer and use it in GitHub Desktop.
This file contains 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
<script> | |
// function checkTypeCount() { | |
// | |
// $(".type").change(function () { | |
// let type = $(this).val(); | |
// | |
// let typeCount = 0; | |
// | |
// if (type=='m') { | |
// typeCount = 10; | |
// } else { | |
// typeCount = 0; | |
// } | |
// | |
// return typeCount; | |
// | |
// }); | |
// | |
// } | |
$(".char-textarea").on("keyup",function(event){ | |
checkTextAreaMaxLength(this,event); | |
}); | |
function checkTextAreaMaxLength(textBox, e) { | |
let smsCount = 1; | |
let charCount = 0; | |
// charCount += typeCount; | |
charCount += textBox.value.length; | |
if (charCount > 160) { | |
smsCount++; | |
} | |
if (charCount > 306) { | |
smsCount++; | |
} | |
if (charCount > 459) { | |
smsCount++; | |
} | |
$(".char-count").html(charCount); | |
$(".sms-count").html(smsCount); | |
return true; | |
} | |
$(document).ready(function(){ | |
$("#type").change(function(){ | |
var type = $(this).val(); | |
var textarea = $(".char-textarea"); | |
if (type === 'm') { | |
textarea.val(textarea.val() + ' STOP AU 36111'); | |
} else { | |
textarea.val(textarea.val().replace(' STOP AU 36111','')); | |
} | |
textarea.keyup(); | |
}); | |
}); | |
/* | |
Checks if the keyCode pressed is inside special chars | |
------------------------------------------------------- | |
@prerequisite: e = e.keyCode object for the key pressed | |
*/ | |
function checkSpecialKeys(e) { | |
if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40) | |
return false; | |
else | |
return true; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment