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.


<script src=""></script>
<script type="text/javascript" src=""></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 );


<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()">