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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:33:23+00:00 2026-06-09T23:33:23+00:00

I am trying to set a password to a form. I basically want someone

  • 0

I am trying to set a password to a form. I basically want someone to type a password into a password field and hit submit and if the password is right, it redirects them to buybutton.php in the same window. If the password isn’t right, a javascript alert pops up that says ‘Password wrong’. I’ve tried to write out the Javascript but no action is happening when the button is clicked. What have I done wrong in my code below? Thanks for the help!

<!DOCTYPE html>
<body width="950" height="300" style="background-image:url('giftcard_bg.jpg');">
<head>
<SCRIPT LANGUAGE="JavaScript">
    function goForit() {
      var passwd;
      passwd = this.document.giftForm.pass.value;
      if(passwd=="samsamsam"){
      window.open ('buybutton.php','_self',false)
      }
      else{
      alert('Password wrong');
      }
    }
</SCRIPT>
</head>


<div style="position:absolute; top:150px; left:285px; text-align:center;">
    <form id="giftForm">        
        <input type="password" id="pass" placeholder="Enter Secret Code" style="font-size:150%;"/>
        <br />
        <input type="button" onClick="goForit()" value="Submit" style="font-size:150%; margin-top:15px;" />                 
     </form>
</div>

</body>
</html>
  • 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-06-09T23:33:24+00:00Added an answer on June 9, 2026 at 11:33 pm
    passwd = this.document.giftForm.pass.value; 
    

    causes an error try

    passwd = document.getElementById('pass').value;
    

    You were missing a ; too after window.open ('buybutton.php','_self',false)

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

Sidebar

Related Questions

Im trying set the single table inheritance model type in a form. So i
I am trying to set minimum password requirements for my membership provider in Umbraco.
I'm pretty new to openLDAP and I am trying to set up a password
I'm trying to set this up where the user gives username and password in-app,
I have a database set up with email and password, I'm trying to use
Trying to set up a new project, and running into a weird issue. I
I'm trying to set up a simple login using AuthLogic into my User table.
Im trying to set up a log-in and password page for my site. This
I am trying to set-up a registration form that sends a welcoming email to
I am trying to scrape form field IDs using Beautiful Soup like this for

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.