javascript - I need to mask the incoming number and show only last 4 digits? -


i want write mrender function j query datable give , hide , show link incoming data.

i have 2 columns in 1 description , other card number. now, when card number ajax call, need have show , hide link in second column card number displayed.

when data gets populated, should show show link -

on click of link should show hide link -

i new j query , java script thing.

would appreciate help. thanks

function displaycardlist() {     otable = $('#cardtable').datatable({         "aadata": cardlist,         "aocolumndefs": [             {                 "atargets": [0],                 "sclass": "card name",                 "mdata": "description"               },             {                 "atargets": [1],                 "sclass": "cardnumber",                  //i need write function here..             }         ]     });     $('#cardtable').show(); } 

this display 'show' link in table cell:

'mrender': function (data, type, full) {           return '<span class=\'hidden\'>' + full[0].substring(full[0].length - 4) + '</span>' +            '<a href=\'javascript:;\' class=\'hidden\' id=\'hide\'>hide</a>' +            '<a href=\'javascript:;\' id=\'show\'>show</a>'; } 

javascript click event handle show/hide

$(document).on("click", "a.show", function (e) {     // clicked object     var lnk = $(this);     // toggle visibility (ie hide 'show' link)     lnk.toggle();     // toggle visibility of previous element(ie show 'hide' link)     lnk.prev().toggle();     // toggle visibility of previous element(show span tag containing card no)     lnk.prev().prev().toggle();  }); 

this 'rough & ready' example, should started , you're new jquery, isn't difficult understand. if meets requirements can refine it.
mention there legal implications surrounding storage of card numbers (ie shouldn't unless have met requirements), i'm guessing exercise.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -