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

  • Home
  • SEARCH
  • 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 3451826
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:11:14+00:00 2026-05-18T09:11:14+00:00

I am working on this script, and for some reason, it is acting as

  • 0

I am working on this script, and for some reason, it is acting as if fn.style.borderColor always equals #F00. All I want is for the second one to execute if and only if the first if has been executed.

function vfn() {
   if (fnl<1){
      na.innerHTML= "This field is required.";
      fn.style.borderColor="#F00";
   } 
   else if (fn.style.borderColor="#F00" && fnl>1) {
      if(lnl>1){
         na.innerHTML= "OK";
         setTimeout("na.innerHTML = ''",1500)
      }
      fn.style.borderColor="#0F0";
      setTimeout("fn.style.borderColor='';",1500)
   }
   return false
}

I tried using variables and did something like this, but it didn’t work at all.

var error = 1
if (error = 1) {
    alert("error1");
    var error = 2
}
else if (error == "2") {
    alert("error2")
    var error = 1
}

So how can I make this work?

————————————->>EDIT<<————————————

Ok, so I changed it to this

  function vfn() {
      if (fnl<1){
        na.innerHTML= "This field is required.";
        fn.style.borderColor="#F00";
        }
      else if (fn.style.borderColor == "#F00" && fnl>1){
        if(lnl>1){
            na.innerHTML= "OK";
            setTimeout("na.innerHTML = ''",1500)}
        fn.style.borderColor="#0F0";
        setTimeout("fn.style.borderColor='';",1500)
        }

        return false}

and what’s happening is that the border color is changed to red when the field is empty, which is what should happen, But when the field is filled in properly, it is SUPPOSED to change to green, then after 1.5 seconds, change back to default, but instead, what actually happens is that it stays red, as if it is ignoring the else if block of code, even though the field is already red (the fn.style.borderColor=”#F00″).

  • 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-18T09:11:15+00:00Added an answer on May 18, 2026 at 9:11 am

    Try to make your else if look like this:

    else if (fn.style.borderColor == "rgb(255, 0, 0)" && fnl>1){

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so im working on this php image upload system but for some reason
I'm trying to get this simple PowerShell script working, but I think something is
I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the
I'm still working with this huge list of URLs, all the help I have
Hello I am working with a simulator that uses rcS scripts to boot, this
I'm working this source code: #include <string> #include <vector> #include <iostream> #include <istream> #include
I've been working on this for a few days now, and I've found several
I have been working on this for the greater part of the day and
I am working on this yahoo pipe Regex and I found a bug I'm
So I'm working on this class that's supposed to request help documentation from a

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.