Click here to Skip to main content
14,870,936 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
sorry for the questions, im just really having trouble in this part. when the user doesn't enter a value in the input box, it says input required like its meant to, but after ive written the inputs for all the correct boxes the input required error message doesn't go away

What I have tried:

if(product =="" || product1 == "" || product2 == "" || product3 == ""  || product4 == "" ){
  text="**Input Required**";
  errormsg.innerHTML = text;
  return false;
}
Posted
Updated 14-Apr-21 5:53am
v4

1 solution

You need to tell the code what to do in the case when all fields have been filled in
JavaScript
if(product =="" || product1 == "" || product2 == "" || product3 == ""  || product4 == "" ){
  text="**Input Required**";
  errormsg.innerHTML = text;
  return false;
}
else {
  errormsg.innerHTML = "";
  return true;
}
   
Comments
Richard MacCutchan 13-Apr-21 11:51am
   
We have no idea how, or where in your form, you are validating these fields.
Arfat M 14-Apr-21 1:45am
   
Code is correct just debug the code by putting breakpoint.
Check this link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900