Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:25:18+00:00 2026-05-31T07:25:18+00:00

Greetings again helpers, I have these snips: <head> <SCRIPT LANGUAGE=JavaScript> <!– Begin function validate()

  • 0

Greetings again helpers,

I have these snips:

<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function validate() {
missinginfo = "";
if (document.form.catdescription.value == "0") {
missinginfo += "\n     -  Category CANNOT be blank";
}
if (document.form.pcode.value == "")  {
missinginfo += "\n     -  Product Code CANNOT be blank";
}
if (document.form.pname.value == "") {
missinginfo += "\n     -  Product Name CANNOT be blank";
}
if (document.form.pdescription.value == "") {
missinginfo += "\n     -  Product Description CANNOT be blank";
}
if (( form.IsSpecial[0].checked == false ) && ( form.IsSpecial[1].checked == false )) {
missinginfo += "\n     -  please check Yes or No";
}
if ((document.form.pphoto.value == "") || (document.form.pphoto.value == "NA"))
 {
missinginfo += "\n     -  Photo is either blank or does not contain NA";
}
if (document.form.unitprice.value == "") {
missinginfo += "\n     -  Price is NOT blank";
}
if (document.form.file2.value == "") {
missinginfo += "\n     -  Browse a picture to upload";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"Please ensure that:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}
//  End -->
</script>
<script type="text/JavaScript">
<!-- Begin
function ChangeDiv(id)
{
if(id == "No")
{
document.getElementById('nof').style.display = "block";
document.getElementById('yesf').style.display = "none";
}
else
{
document.getElementById('nof').style.display = "none";
document.getElementById('yesf').style.display = "block";
}
}
//  End -->
</script>
</head>
   <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=4 BORDERCOLOR="YELLOW" >
    <tr>
    <td class="body1" div align="right">
       <div id="yesf" style="display:none;">
       Promo Start Date:
      <input type="text" name="pstartdate" class="normaltxt"><br>
       Promo End Date:
      <input type="text" name="penddate" class="normaltxt"><br>
       PROMO Price:
      <input type="text" name="txtsprice" value="">
      </div>
      </td>
    </tr>
    <tr>
     <td class="body1" div align="right">
     <div id="nof">
      Regular Price:
      <input type="text" name="unitprice" value="">
        </div>
        </td>
    </tr>
</table>

These are relevant code.

If the user clicks on the Yes radio button, all form fields inside the –> are displayed. If the user checks the No radio button the only form field called price is displayed for data entry.

So far so good. The issue I am struggling with is how to make sure the Javascript validation code I posted above only raises an alert for only visible form fields.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:25:20+00:00Added an answer on May 31, 2026 at 7:25 am

    I’m sorry to say it but, that code is nasty!

    Replace those kind of lines:

    if (document.form.catdescription.value == "0") {...
    

    With:

    if ($('#catdescription').val() == "0") {...
    

    Then you can check validate it only if it’s visible easly with the :visible selector:

    if ($('#catdescription:visible').val() == "0"){
        missinginfo += "\n     -  Category CANNOT be blank";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings all, I have a simple JQuery function which is bound to an ASP:Button
Greetings, I have a bash script that parses ZIP files we receive from a
Greetings again, I have this problem again on C but now using struct. Having
Greetings , and again today when i was experimenting on language C in C99
Greetings. I have written a little python script that calls MySQL in a subprocess.
Greetings! I have a Repeater control that's using an XmlDataSource control. <asp:FormView id=myFormView runat=server
Greetings! I'm trying to have a UIWebView controlled from generated events. Is there a
Greetings, With javascript, I am trying to make a very easy animation, an image
Greetings, I have a form where employees enter comments in a multiline textbox with
Greetings, We have an application written in .net 3.5 that uses wcf and also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.