Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Obfuscated Javascript?
Message
From
16/02/2013 11:41:21
 
 
To
15/02/2013 14:39:42
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01566169
Message ID:
01566228
Views:
49
now that is a line encouraging you to be fluent in, not with javascript ;-)

>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>
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform