-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
34 lines (26 loc) · 873 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
jQuery(document).ready(function($) {
$('input[name="pn_text"]').on('input',function(){outputLength()});
function outputLength(){
var length = 42
+ checkLength( $('input[name="pn_text"]').val() )
if (length > 255) {
$("#output").html("<b style='color:#f00'>"+length+"</b>");
$("#push_button").prop('disabled', true);
}else{
$("#push_button").prop('disabled', false);
$("#output").html(length);
}
}
function checkLength(text) {
var escapedStr = encodeURI(text);
if (escapedStr.indexOf("%") != -1) {
var count = escapedStr.split("%").length - 1;
if (count == 0) count++;
var tmp = escapedStr.length - (count * 3);
count = count + tmp;
} else {
count = escapedStr.length;
}
return count;
}
});