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