Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67441

Console error while validating gstin in Polymer JS

$
0
0

I have a Polymer JS code which validates GSTIN:

<dom-module id="gst">
    <template>
            <div>
                <label for="gstid" class="gstlabel">GSTIN</label>
                <input type="text" id="gstid" name="gstid" on-submit="gstid_validation(gstid)">
            </div>
    </template>

    <script>
        Polymer({
            is: 'gst',
            gstid_validation: function(gstin) {
                var gstin_count = length(gstin);
                var pattern = qr/\d{2}[A-Z]{5}\d{4}[A-Z][A-Z\d]Z[A-Z\d]/;
                return 'Invalid GSTIN' if ( gstin_count != 15 && gstin =~ pattern);
            }.
        });
    </script>
</dom-module>

I get the following 2 issues:

Issue 1: I get the error in console:

Uncaught SyntaxError: Unexpected token if

Issue 2: The input field gstid is not getting displayed

Can anyone please help?

Thanks in advance


Viewing all articles
Browse latest Browse all 67441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>