0

I'm trying to make the simplest of logins. Simply need to have a 1 static username/password to proceed to next html page in my directory via button click.

I've tried using this method but doesn't seem to work for me.

<input type="text" name="login" required pattern="user123">
<input type="text" name="password" required pattern="password1234">

Any ideas would be helpful. Heres the full login if it helps http://jsfiddle.net/aHzAP/

asked Oct 24, 2013 at 19:34
3
  • 2
    What did you expect this to do? You need to connect your form to a backend of some kind that authenticates the user's credentials. Just throwing a couple form fields onto a page is not going to produce a working login. How did you think it was going to determine the whether or not the user submitted a valid username and password? Commented Oct 24, 2013 at 19:40
  • 1
    I'm lost for words. You've tagged your question with html5, yet you're using tables for layout, <center> tags and <font> tags Commented Oct 24, 2013 at 19:41
  • Argh argh argh <font>. But (one) problem is that you're circumventing the native validation with the redirection in the onclick attribute. Why have it at all? Commented Oct 24, 2013 at 19:41

2 Answers 2

1

The key to the question is that the asker wants the user name and password to be static.

Why not use very simple Javascript to do this?

 <input type="text" id="login" required>
 <input type="text" id="password" required>
 <input type="button" id="goButton" onclick="checkLoginPass()" />
 <script>
 var checkLoginPass = function () {
 var login = document.getElementById("login").value;
 var pass = document.getElementById("password").value;
 if (login === "user123" && pass === "password1234") {
 window.location.replace("http://www.someurlhere.com");
 }
 else {
 //do something else;
 }
 }
 </script>
NicolasMoise
7,27910 gold badges47 silver badges65 bronze badges
answered Oct 24, 2013 at 19:43
Sign up to request clarification or add additional context in comments.

4 Comments

Have you learned nothing from the question you 'borrowed' this code from? stackoverflow.com/questions/19575763/…
my answer was posted before this question was asked... I think the 'borrowing' is the other way around here...
Oh lol I see. I just thought it was funny because I was just coming from that question.
Lol, it's ok. The original asker decided to post a whole new question instead of just adding a comment and asking why it wasn't working... At least they found the solution they were looking for, that's all that really matters... and thanks for the correction on the location.replace, i got really close without any testing :)
0

Your should have an action and a method attribute, onclick won't send any information to the pages it will lead when clicked

<form action="AdminResults.php" method="post">

Edit: You will need something like php on the action page to check if the authentication is valid

answered Oct 24, 2013 at 19:43

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.