troubleshooting Question

Required fields from a dynamic number of form fields

Avatar of nisupport
nisupport asked on
JavaScriptPHPMySQL Server
6 Comments1 Solution309 ViewsLast Modified:
I am using PHP to program a page that loops through to see how many items I have set on the backend. It performs a while loop to show the inputted number of items set on the backend. It starts like this:
 <? $cnt = $row->numberofitems + 1;
      $i = 1;
      while($i < $cnt)
      $queryb = "SELECT * FROM table;

So I might have 3 form fields added or whatever number is set. My question is how can I set these up to be required. I am using javascript to check required fields and the code is shown below:

function MM_validateForm(){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
if (document.contactfrm.fname.value == ''){
errors+='-First name is required.\n';
if (document.contactfrm.lname.value == ''){
errors+='-Last name is required.\n';
if ( == ''){
errors+='-Email address is required.\n';
if (errors)
alert ('The following errors occured:\n'+errors);
document.MM_returnValue = (errors == '');

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros