Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Obfuscated Javascript?
Message
De
15/02/2013 14:39:42
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Titre:
Obfuscated Javascript?
Divers
Thread ID:
01566169
Message ID:
01566169
Vues:
77
Here's some code from a page that gets and validates 3 variables - numeric Access Code and Cheque Number, and a date chosen from a date picker. I think I follow most of the code; the lower part first checks that the values are not blank. If they are not, it then runs a line of code I don't understand, then returns true.

What does that line do? ( the one that ends in .slice(-5) )
<script type="text/javascript">
    $(document).ready(function () {
        $("#ChequeNumber").numeric({ decimal: false, negative: false });
        $("#AccessCode").numeric({ decimal: false, negative: false });
    });

    $('#datePicker').bind('datebox', function (e, passed) {
        if (passed.method === 'close') {
            $('#VisitDate').val($('#datePicker').data('datebox')._formatter('%m/%d/%Y', $('#datePicker').data('datebox').theDate));
        }
    });

    $(document.forms[0]).submit(function () {
        if ($("#ChequeNumber").val() == "") {
            $(".error").html("Cheque # is not a recognized number.");
            $("#ChequeNumber").focus();
            return false;
        } else if ($("#VisitDate").val() == "") {
            $(".error").html("Please enter your date of visit and try again.");
            $("#VisitDate").focus();
            return false;
        } else if ($("#AccessCode").val() == "") {
            $(".error").html("Access code is not a recognized number.");
            $("#AccessCode").focus();
            return false;
        }
        else {
            $("#EntryCode").val($("#AccessCode").val() + $('#datePicker').data('datebox')._formatter('%m%d%Y', $('#datePicker').data('datebox').theDate) + ("00000" + $("#ChequeNumber").val()).slice(-5));

            return true;
        }
    });
</script>
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform