/    Sign up×
Community /Pin to ProfileBookmark

validating of form…… and any suggestions pls!

Hi guys

I have taken this little test project from a friend for her club…I saw this as an opportunity to give my JavaScript and PHP I have been studying in the last month a beginner’s shot.

The project constitutes a simple voting site …. Members have been send their pins in the post what the members then does is to log in using their pin number on login.php, on the login.php I want to validate as follows:

[1] to make sure no empty form can be submitted
[2] that the pin number, which should consist of 10 mixtures of letter and digits (at least 3 digits, 5 capital letters and 2 digits in any order) should be validated for this arrangement

If successful at log in the voter then is taken to vote.php….. where they get to choose a radio button to select their vote and then click submit.

I need to pass the pin from login.php to the vote.php page bcos when the voter clicks on the vote submit button I want the confirm.php to read (I believe I need to use a hidden form element to pass the pin.)
Your pin is…….and u have voted for ………. That concludes the vote.
(This I hope to do in the form of form processing using PHP by extracting the $pin and $vote).

(There is one other condition …the voter must not be able to vote more than once!) – this I am not sure how to do it).

1.Pls can someone tell me if I am on the right path or is there a SIMPLER way to accomplish this task?

2.So this what I have done so far and I have created this JavaScript code to validate the login. php but I am missing something bcos it is not working?

<script language=”JavaScript”>
function validateform()
{
//check pin
if (document.forms[0].elements[0].value ==””)

alert (“please enter your pin!”);
return false;
}

</script>

It traps any attempt to submit an empty form but on input of some digits and I click the submit button it does not take me to the vote.php page

  • 3. I have also written a little code for validating the pin pattern.
    <script language=”JavaScript”>
    Var objRegExp =/d{3}A-Z{5}d{2}/;
  • Function validateform (checkpin )

    { if (pin != objRegExp)
    alert (“pls enter ur correct pin”);

    Return false;

    else

    return true;

    }

    </script>

    Can someone pls tell me what I am missing in the two codes or how to get them to work pls and any suggestions regards the way I plann to make the voting web site to work would be greatly appreciated.

    Many Thanks in Advance.

    [B]<script language=”JavaScript”>[/B] [B]<script language=”JavaScript”>[/B]

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @capridv spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.7,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...