Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Obfuscated Javascript?
Message
De
15/02/2013 14:55:41
 
 
À
15/02/2013 14:39:42
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01566169
Message ID:
01566176
Vues:
69
It sets the value of EntryCode to AccessCode + a formatted date from the date picker + "00000" + a slice of the check number. slice is documented at http://api.jquery.com/slice/

Are you familiar with jQuery?

>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>
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform