Skip to content

Instantly share code, notes, and snippets.

@deepakkadarivel
Created October 19, 2018 09:21
Show Gist options
  • Save deepakkadarivel/158fb8eb0dfb6788a2e663d401f270fa to your computer and use it in GitHub Desktop.
Save deepakkadarivel/158fb8eb0dfb6788a2e663d401f270fa to your computer and use it in GitHub Desktop.

Revisions

  1. deepakkadarivel created this gist Oct 19, 2018.
    42 changes: 42 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="description" content="[add your bin description]">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Validation logic check.</title>
    </head>
    <body>

    <script id="jsbin-javascript">
    function minLength(min, value) {
    return ((value && value.toString().length >= min) || !value) ? undefined : 'invalid';
    }


    function minLengthNew(min, value) {
    return (value && value.toString().length < min) ? 'invalid' : undefined;
    }

    console.log(minLength(3, '12'));
    console.log(minLength(3));
    console.log(minLengthNew(3, '12'));
    console.log(minLengthNew(3));
    </script>



    <script id="jsbin-source-javascript" type="text/javascript">function minLength(min, value) {
    return ((value && value.toString().length >= min) || !value) ? undefined : 'invalid';
    }


    function minLengthNew(min, value) {
    return (value && value.toString().length < min) ? 'invalid' : undefined;
    }

    console.log(minLength(3, '12'));
    console.log(minLength(3));
    console.log(minLengthNew(3, '12'));
    console.log(minLengthNew(3));</script></body>
    </html>
    13 changes: 13 additions & 0 deletions jsbin.gelidak.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function minLength(min, value) {
    return ((value && value.toString().length >= min) || !value) ? undefined : 'invalid';
    }


    function minLengthNew(min, value) {
    return (value && value.toString().length < min) ? 'invalid' : undefined;
    }

    console.log(minLength(3, '12'));
    console.log(minLength(3));
    console.log(minLengthNew(3, '12'));
    console.log(minLengthNew(3));