I have this function I use to store items (voucher codes) based on some rules...
$("#serial_number").submit(function (e) {
e.preventDefault();
console.log('started');
if (param == 'groupon' || param == 'livingsocial') {
var secretS = $('#serial').val();
var secretP = $('#pin').val();
if ((/(?=[a-fA-F0-9]*[a-fA-F])[a-fA-F0-9]{10}/.test(secretS) === true) || (secretS.length == 13)) {
var s = $('#serial').val();
var p = $('#pin').val();
var item = {}
item["serial"] = s;
item["pin"] = p;
item["product_code"] = '74';
item["promo_code"] = '74';
item["covers"] = 2;
jsonObj.push(item);
as you can see based on rexEg rule I write in IF condition I add an item to jsonObj
so if it's valid I push into jsonObj an item.
If I type just once the correct serial based on rule like 123456789a everything is fine and I have this [{serial: "123456789a", pin: undefined}]
which is fine...
Problem is if:
attempt - User type something like 1234 and try to submit a form but based o rules its item not stored into jsonObj
attempt - User type ggghhh55 also not stored into jsonObj
user finally submit correct serial like (123456789a) but then its added 3 times so I have this:
[{serial: "123456789a", pin: undefined}, {serial: "123456789a", pin: undefined}, {serial: "123456789a", pin: undefined}]
Why? Why submit to form add item 3 times... should add it just once ...
Finally when the user enter correct serial then the form is submitted number of previous attempts ... so if there is 3 unsuccessful attempts form is submitted 3 times ...
Seems like you need to reset your jsonObj after each attempt
I'm not able to pass the state value to the method or function in React [closed]
How to access array index of Cloud Firestore using query in Flutter?
Getting an unwanted space between Nav Items in Navbar Angular
PHP Script INSERT INTO SELECT does not insert, with no errors [closed]
SQL query to select students who have taken all subjects from subjects table
Displaying Dynamic placeholder content on Textbox in ReactJS
Extracting Parameters from Redirect URI - QuickBooks API / Python
My goal: The user picks selection 1 and the corresponding div will showThe user picks selection 2, the selection 1 div disappears and shows the selection 2's div
I’ve been trying to incorporate an auto scroll function on my website (live here)I want it to scroll to the content 6 seconds after load, but only if the user is on the very top of the page and hasn’t scrolled enough to uncover the #introduction element
I have on keyup and mask for phone numbers, I need to get only digits, not symbols on mask, but it is not working, please let me know my mistake
The method is called in the ready eventOn the first call it works