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 7400525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:15:46+00:00 2026-05-29T04:15:46+00:00

I am trying to bring in an external style sheet from a css file

  • 0

I am trying to bring in an external style sheet from a css file in an if statement. I have several textboxes and I need for if on the click of a button a pop up come up and it say the entire form should be filled and the background color change to red. I have this in my HTML file:

<style type="text/css">

@import url("mysheet.css");

</style>

<script type="text/javascript">
function validateform()
{
var x=document.forms["CustInfo"]["Fname"].value;
if (x == null || x == "")
{
    alert("The entire form must be filled out");
    return false;
}
</script>

In my CSS file I simply have:

.formalert{
    background-color: Red;
}

How can I change that “alert” to call my formalert?

  • 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-29T04:15:46+00:00Added an answer on May 29, 2026 at 4:15 am

    The simple way to do this is to always include the style, but only set your form to have that className if it fails validation.

    <style type="text/css">
    .formalert{
        background-color: Red;
    }
    </style>
    
    <script type="text/javascript">
    function validateform(oForm)
    {
        var x=document.forms["CustInfo"]["Fname"].value;
        if (x == null || x == "")
        {
            alert("The entire form must be filled out");
            oForm.className += ' formalert';
            return false;
        }
        return true;
    }
    </script>        
    
    <form action="" method="post" onsubmit="return validateform(this);">
    ...
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to bring data into my app from an external file. everything's working
I have an external Javascript file and i am trying to alert the value
I'm trying to load data from an external csv file that needs to be
I'm trying to add an external icon from an *.ico file to a window
I have to move some hard-coded strings to external resources files, and I'm trying
So I am trying to populate the slideshow div with images from a external
I have been trying to call some functions from a library provided by a
I've been trying to play an external sound file in Flash and failing miserably.
I'm trying to bring myself up to speed on C#, having never developed for
I'm trying to bring a legacy C# .NET 1.1 application into the modern era.

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.