Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

javascript won't populate text field when called

  • 02-07-2014 06:28PM
    #1
    Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭


    Hi,

    i hav this javascript which reads information, strips it down and i want it to repopulate the field on keyup.

    i know its being called as i can get it to write the data to a span but not to a text box value:

    [HTML]$("#voter_ID").keyup(function (e) {

    //removes spaces from voter_ID field
    $(this).val($(this).val().replace(/\s/g, ''));

    var voter_ID = $(this).val();

    if(voter_ID.substring(0, 1) == "%" && voter_ID.length >= 4) {
    var cardnumber = voter_ID.substring(voter_ID.lastIndexOf(";")+1,voter_ID.lastIndexOf(";")+19);
    //var cardnumber = voter_ID.split("?")[0];
    $("#swipe-result").html('<br />' && cardnumber);

    $("tester").val(cardnumber);

    //$("#voter_ID").val(cardnumber);
    }

    //if the number doesn't match a certain length ignore it.
    //if(voter_ID.length != 4 || voter_ID.length != 16 || voter_ID.length != 32) {
    //$.post('useridfail.php',{'voter_ID':voter_ID},function(data) {
    //$("#user-result").html('<img src="imgs/not-available.png"><br /><span class="error-text">Invalid Clubcard or till receipt</span>');
    //});
    //}
    $("#user-result").html('<img src="imgs/ajax-loader.gif" style="margin-bottom:4px;" />');
    delay(function() {

    if(voter_ID.length != 4 || voter_ID.length != 16 || voter_ID.length != 18 || voter_ID.length != 32) {
    $("#user-result").html('<img src="imgs/not-available.png" style="margin-bottom:4px;" onload="timedRefresh(5000)" /><br /><span class="error-text">Invalid Clubcard or till receipt</span>' && '');
    }


    if(voter_ID.length == 4 || voter_ID.length == 16 || voter_ID.length == 18 || voter_ID.length == 32){

    $.post('check_username.php', {'voter_ID':voter_ID}, function(data) {
    $("#user-result").html(data);
    });
    }

    }, 1200);





    });
    });
    [/HTML]

    I'm trying to get it to write the card number variable back to the voter_ID or tester text box.

    any help much appreciated.

    thanks


Advertisement