View | Details | Raw Unified | Return to bug 10267
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-8 / +22 lines)
Lines 35-50 $(document).ready(function() { Link Here
35
	[% END %]
35
	[% END %]
36
});
36
});
37
37
38
function update_cardnumber_warning(size){
39
    var max_len = [% maxlength_cardnumber %];
40
    if ( size >= max_len ) {
41
        $("#cn_max").show();
42
    } else {
43
        $("#cn_max").hide();
44
    }
45
}
46
38
$(document).ready(function() {
47
$(document).ready(function() {
39
    $("#cn_max").hide();
48
    $("#cn_max").hide();
40
    var max_len = [% maxlength_cardnumber %];
49
    var content;
41
    $("#cardnumber").change(function(){
50
    $("#cardnumber").on("keydown", function(e){
42
        if ( $("#cardnumber").val().length >= max_len ) {
51
        content = $(this).val();
43
            $("#cn_max").show();
52
    });
44
        } else {
53
    $("#cardnumber").on("keyup", function(e){
45
            $("#cn_max").hide();
54
        // .val() will return the value of the input after the key has been released
46
        }
55
        var l = $(this).val().length;
56
        if ( l == content.length + 1 ) { l--; }
57
        update_cardnumber_warning(l);
47
    });
58
    });
59
    $("#cardnumber").bind("paste", function(e){
60
        var pastedData = e.originalEvent.clipboardData.getData('text');
61
        update_cardnumber_warning(pastedData.length - 1);
62
    } );
48
    var toggle_quick_add = $(".toggle_quick_add");
63
    var toggle_quick_add = $(".toggle_quick_add");
49
    $(toggle_quick_add).click(function(e){
64
    $(toggle_quick_add).click(function(e){
50
        toggle_quick_add.toggle();
65
        toggle_quick_add.toggle();
51
- 

Return to bug 10267