www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with Validation

  1. #1
    Join Date
    Nov 2012
    Posts
    7

    Help with Validation

    This is my code, I need help validating the fields that the users types in. If anyone could help me out, I would appreciate it very much.

    <html>
    <head>

    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>


    <script>
    $(document).ready(function(){
    $("#commentForm").validate();
    });
    </script>
    <script>

    var lastNames= [];
    var firstNames= [];
    var percent = [];
    var grade = [];


    function addToArray() {

    var ln = document.getElementById('lastName');
    var fn = document.getElementById('firstName');
    var gr = document.getElementById('percent');
    var per = document.getElementById('grade');

    lastNames[lastNames.length] = ln.value;
    firstNames[firstNames.length] = fn.value;
    percent[percent.length] = per.value;
    grade[grade.length] = gr.value;



    alert( lastNames );
    alert( firstNames );

    alert( percent );
    alert( grade );

    }

    </script>
    </head>
    <body>
    <form class="entry" id="enter" method="get" action="">
    Enter last name: <input type="text" id="lastName"><br>
    Enter first name: <input type="text" id="firstName"><br>
    Enter percent: <input type="text" id="percent"><br>
    Enter grade : <input type="text" id="grade"><br>
    <input type="button" value="Submit" onClick="addToArray()">
    </body>
    </html>

  2. #2
    Join Date
    Jan 2005
    Posts
    366
    What validation do you need? Minimum number of characters, specific words/phrases, or just "not empty" ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles