Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 days ago.
Improve this question
I have no clue what happened... I debugged all the files and searched "username" to try to find the second parameter username, but instead of email, username appears again:
http://127.0.0.1:2350/create?username=&pass=&username=
Here are the server code that hosts this html page:
#app.route('/create', methods=['GET', "POST"])
def createUser():
connection = establishSqliteConnection(os.path.join(os.getcwd(), 'users.db'))
connection.execute(table_connection)
username = request.args.get('username')
password = request.args.get('pass')
email = request.args.get('email')
emailTemp = email
if username is not None and password is not None:
passwordHashed = generate_password_hash(password)
dateStr = f'{date.today().strftime("%B %d, %Y")} {datetime.now().strftime("%H:%M:%S")}'
command = f'''
INSERT INTO "users" (id, username, passwordhashed, email, emailVerified, date)
VALUES ('{str(uuid.uuid4())}', '{username}', '{passwordHashed}', '{email}', 0, '{dateStr}')
'''
connection.execute(command)
connection.commit()
connection.close()
return 'Account created. Please verify your account with the link sent to your inbox to activate your account. This page will redirect in 5 seconds. <body onload="setTimeout(() => {window.location.href=\'/login?username=%s&pass=%s\'}, 5000)"></body>' % (username, password)
else:
user_agent = request.headers.get('User-Agent')
user_agent = user_agent.lower()
if 'iphone' in user_agent or 'android' in user_agent or 'ipad' in user_agent:
return '<html><body onload="alert("Login currently not supported on mobile devices.");"></body></html>'
else:
return render_template('/createAccount.html')
HTML page:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Create account</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/static/fonts/iconic/css/material-design-iconic-font.min.css">
<link rel="stylesheet" type="text/css" href="/static/vendor/animate/animate.css">
<link rel="stylesheet" type="text/css" href="/static/vendor/css-hamburgers/hamburgers.min.css">
<link rel="stylesheet" type="text/css" href="/static/vendor/animsition/css/animsition.min.css">
<link rel="stylesheet" type="text/css" href="/static/vendor/select2/select2.min.css">
<link rel="stylesheet" type="text/css" href="/static/vendor/daterangepicker/daterangepicker.css">
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="/static/css/createAccount.css">
<link rel="icon" type="image/x-icon" href="{{url_for('static', filename='img/favicon.ico')}}">
</head>
<body>
<div class="limiter">
<div class="container-login100" style="background-image: url('/static/img/createaccount_bg.jpg');">
<div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-54">
<form class="login100-form validate-form">
<span class="login100-form-title p-b-49">
Create account
</span>
<div class="wrap-input100 validate-input m-b-23" data-validate = "Username is reauired">
<span class="label-input100">Username</span>
<input class="input100" type="text" name="username" id="username" placeholder="Type your username">
<span class="focus-input100" data-symbol=""></span>
</div>
<div class="wrap-input100 validate-input" data-validate="Password is required">
<span class="label-input100">Password</span>
<input class="input100" type="password" name="pass" id="password" placeholder="Type your password">
<span class="focus-input100" data-symbol=""></span>
</div>
<br>
<div class="wrap-input100 validate-input m-b-23" data-validate = "Email is reauired">
<span class="label-input100">Email</span>
<input class="input100" type="email" name="username" id="email" placeholder="Type your email">
<span class="focus-input100" data-symbol=""></span>
</div>
<br>
<div class="container-login100-form-btn">
<div class="wrap-login100-form-btn">
<div class="login100-form-bgbtn"></div>
<button class="login100-form-btn" onclick="createAccount()">Create</button>
</div>
</div>
<div class="flex-col-c p-t-155">
<span class="txt1 p-b-17">
Or
</span>
<a href="/login" class="txt2">
Sign in
</a>
</div>
</form>
</div>
</div>
</div>
<div id="dropDownSelect1"></div>
<script src="/static/vendor/jquery/jquery-3.2.1.min.js"></script>
<script src="/static/vendor/animsition/js/animsition.min.js"></script>
<script src="/static/vendor/bootstrap/js/popper.js"></script>
<script src="/static/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/vendor/select2/select2.min.js"></script>
<script src="/static/vendor/daterangepicker/moment.min.js"></script>
<script src="/static/vendor/daterangepicker/daterangepicker.js"></script>
<script src="/static/vendor/countdowntime/countdowntime.js"></script>
<script src="/static/js/create.js"></script>
</body>
</html>
JS file:
function createAccount() {
username = document.getElementById('username').value;
password = document.getElementById('password').value;
email = document.getElementById('email').value;
window.location.href = `/create?username=${username}&pass=${password}&email=${email}`;
}
From the HTMl page, when the create button is pressed, the "createAccount()" function from the js file is triggered. In the javascript function the parameters are correct... username, password, and email.
Any thoughts on this magic?
I searched with the search in workspace function in VSCode but could not find a duplicate function or anything else...
Related
I'm working on creating a dApp using Moralis framework.
The website is very simple.. I created the html for the login page
login.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.88.1">
<title>Tomorrow Marketplace</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/sign-in/">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="signin.css">
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/web3#latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
</head>
<body class="text-center">
<main class="form-signin">
<img class="mb-4" src="tomorrow.svg" alt="" width="72" height="57">
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
<div class="form-floating">
<input type="text" class="form-control" id="user-username" placeholder="username">
<label for="user-username">Username</label>
</div>
<div class="form-floating">
<input type="email" class="form-control" id="user-email" placeholder="name#example.com">
<label for="user-email">Email address</label>
</div>
<button id="btn-login" class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">© 2017–2021</p>
</main>
<script src="main.js"></script>
</body>
</html>
in the main.js
const serverUrl = "https://qqujdxp5bgle.usemoralis.com:2053/server";
const appId = "fZ73Z90MnT7Kj2H4C1JYu8EOSOaHkIRwPQ3V0JtD";
Moralis.start({
serverUrl,
appId
});
async function login() {
const user = await Moralis.User.logIn("username", "email");
user.set("username", document.getElementById("user-username").value);
user.set("email", document.getElementById("user-email").value);
await user.save();
user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate();
}
console.log("logged in user:", user);
}
document.getElementById("btn-login").onclick = login;
The website is not connecting to Metamask knowing that im working on the latest updated snippets for Moralis.
On another note, is Moralis the best framework to work with.. or there is other suggestions.
Appreciate your help and thank you.
GM there!
So since you are logging in or authenticating w/ email + password already, the server will not allow you to authenticate again for another session with Metamask.
If you wanna connect your metamask after email login, use await Moralis.enableWeb3() instead and it will do the job!
Keep in mind that this is legacy now and our moralis library have been renamed moralis-v1 and the moralis library is NodeJS SDK for Moralis 2.0
if you have anymore questions, feel free to contact me and ask question in
Moralis discord: https://moralis.io/joindiscord
Moralis forum: https://forum.moralis.io
Hope this helps, Cheers!
I have a node.js proyect with a Back and FrontEnd. I installed normalizr to normalize the data I use on the backend. I could do it. I send that data to the frontEnd and I want to denormalize to show it. I pasted the normalizr CDN script in my HTML (before my index.js script). When I initialize denormalize, I get this error:
normalizr.browser.min.js:1 Uncaught TypeError:
Cannot read properties of undefined (reading 'denormalize')
at t (normalizr.browser.min.js:1:6345)
at new t.denormalize (normalizr.browser.min.js:1:6585)
at Socket.<anonymous> (index.js:64:22)
at Socket.Emitter.emit (index.js:143:20)
at Socket.emitEvent (socket.js:276:20)
at Socket.onevent (socket.js:263:18)
at Socket.onpacket (socket.js:228:22)
at Manager.Emitter.emit (index.js:143:20)
at Manager.ondecoded (manager.js:200:14)
at Decoder.Emitter.emit (index.js:143:20)
My index.js code is:
socket.on('normalizedData', data => {
let log = document.getElementById('log');
let normalData = new normalizr.denormalize(data.result, data.mesagges, data.entities);
console.log(normalData);
let messages = "";
})
My HTML code is:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-
EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1 class="title">User info</h1>
<form id="userForm">
<label class="form-title">Email</label>
<input class="form-control" name="email">
<label class="form-title">Name</label>
<input class="form-control" name="name">
<label class="form-title">Lastname</label>
<input class="form-control" name="lastname">
<label class="form-title">Age</label>
<input class="form-control" name="age">
<label class="form-title">Nickname</label>
<input class="form-control" name="nickname">
<label class="form-title">Avatar</label>
<input class="form-control" name="thumbnail">
<input class="btn btn-primary" type="submit">
</form>
<span id="productsTemplate"></span>
<section>
<h1>Chat Service</h1>
<div>
<input id="chatBox">
</div>
<p id="log"></p>
</section>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/normalizr#3.6.1/dist/normalizr.browser.min.js">
</script>
<script src="/socket.io/socket.io.js"></script>
<script src="index.js"></script>
</body>
Can anybody help me with this? Thanks!
I get 419 error unknown status and csrf token mismatch, when I try to login in Laravel nova web app through chrome extension. I try to made exception verify csrf token for chrome extensions. Is it possible login in that approach or should I use Laravel passport auth?
popup.js
const url = 'http://local.requestmapper.com/api/user/';
window.onload = function(event) {
const form = document.getElementById('login_form');
var header = new Headers();
header.append("Content-Type", "application/json");
header.append("Accept", "application/json, text-plain, ");
header.append('Access-Control-Allow-Origin', '*');
header.append("X-Requested-With", "XMLHttpRequest");
var formData = new FormData();
for (var i = 0; i < form.length; ++i) {
formData.append(form[i].name, form[i].value)
}
console.log(JSON.stringify(formData));
fetch(url + 'login', {
method: 'post',
credentials: 'same-origin',
headers: header,
mode: 'no-cors',
cache: 'default',
body: formData,
})
.then(data => data.json()
)
.then(data => {console.log(data);
})
.catch((error) => {
console.log('Error:', error);
})
//form.addEventListener('submit', login);
event.preventDefault();
}
popup.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" name="csrf-token" content="{{ csrf_token()}}">
<title>Login</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
</head>
<body>
<div class="form-group">
<form method="post">
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-group" placeholder="example#mail.com">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-group" placeholder="passsowrd">
</div>
</form>
</div>
</body>
<script type="text/javascript" src="popup.js"></script>
</html>
UserController.php
public function login(LoginRequest $request){
$credentials = $request->only('email', 'password');
if(Auth::attempt($credentials)){
return response()->json(['status' => 'success'], 200);
}
}
VerifyCsrfToken.php
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
protected $except = [
'chrome-extension://*'
];
}
update this
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
protected $except = [
'api/*'
];
}
as you using in chrome extensions so you need to set api/*
Now, I get 422 error, because somehow form data passed as empty array value, although I filled form.
Also, I edit popup.html file, forgot to insert name attribute as well as submit button
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" name="csrf-token" content="{{ csrf_token()}}">
<title>Login</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
</head>
<body>
<div class="container">
<div class="card card-default">
<div class="card-header">Login</div>
<div class="card-body">
<div class="form-group">
<form method="post" id="login_form">
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email" class="form-control" placeholder="example#mail.com">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" class="form-control" placeholder="passsowrd">
</div>
<button type="submit" class="btn btn-info">Login</button>
</form>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="popup.js"></script>
</html>
I am making a sample project of Visa Consultancy Software, I am using Javascript, HTML, CSS and Bootstrap and I want to open new page on clicking the home div but I am getting a error i.e eventlistner is null. Kindly help me making my code correct.
JAVASCRIPT FILE
document.querySelector(".btn").addEventListener('click', (e)=>{
document.querySelector(".forget").innerHTML="";
document.querySelector(".password").innerHTML="";
document.querySelector(".email").innerHTML="";
var mail = document.getElementById("maile").value;
var password = document.getElementById("pasw").value;
if (mail == "" && password== "") {
document.querySelector(".forget").innerHTML="Please enter the email id and password";
}
else if (password == "") {
document.querySelector(".password").innerHTML="Please enter the password.";
}
else if (mail==""){
document.querySelector(".email").innerHTML="Please enter the e-mail id";
}
else if (mail=== "himanshusingla256#gmail.com" && password==="1234")
{
window.open("file:///C:/Users/DITSPC3/Desktop/Visa%20Consultancy/Navigation.html");
}
else
{
document.querySelector(".forget").innerHTML="Incorrect email or password";
}
e.preventDefault();
});
function Sidebar()
{
// Container
var onediv= document.createElement('div');
onediv.className= "container1";
onediv.style.background = "lightgray";
onediv.id = "block";
onediv.style.width="20%";
onediv.style.color="white";
onediv.style.overflow="hidden";
onediv.style.display= "inline-block";
document.body.appendChild(onediv);
// row
var row= document.createElement('div');
row.className= "row";
row.id= "row1";
row.style.overflow="hidden";
document.body.appendChild(onediv).appendChild(row);
// column
var one8 = document.createElement('div');
one8.innerHTML="Home";
one8.className="col1 home";
one8.style.fontSize="35px";
one8.style.overflow="hidden";
one8.style.height="158px";
one8.style.paddingLeft="25px";
one8.id="block1";
document.body.appendChild(onediv).appendChild(one8);
var o1= document.createElement('div');
o1.innerHTML="Appointment";
o1.className="col1 appointment";
o1.href="index.html" ;
o1.style.overflow="hidden";
o1.style.fontSize="35px";
o1.style.height="158px";
o1.style.paddingLeft="25px";
document.body.appendChild(onediv).appendChild(o1);
var o2= document.createElement('div');
o2.innerHTML="Manage Documents";
o2.className="col1 document";
o2.style.height="158px";
onediv.style.overflow="hidden";
o2.style.fontSize="35px";
o2.style.paddingLeft="25px";
document.body.appendChild(onediv).appendChild(o2);
var o3= document.createElement('div');
o3.innerHTML="Courses";
o3.className="col1 course";
o3.style.fontSize="35px";
o3.style.overflow="hidden";
o3.style.height="158px";
o3.style.paddingLeft="25px";
document.body.appendChild(onediv).appendChild(o3);
var o4= document.createElement('div');
o4.innerHTML="Applicant Data";
o4.className="col1 applicant";
o4.style.fontSize="35px";
o4.style.overflow="hidden";
o4.style.height="158px";
o4.style.paddingLeft="25px";
document.body.appendChild(onediv).appendChild(o4);
var o5= document.createElement('div');
o5.innerHTML="Log-Out";
o5.className="col1 out";
o5.style.fontSize="35px";
o5.style.overflow="hidden";
o5.style.height="158px";
o5.style.paddingLeft="25px";
document.body.appendChild(onediv).appendChild(o5);
}
// Sidebar();
document.getElementsByClassName(".home").addEventListener('click', ()=> {
window.open("home.html");
});
Navigation Index File
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Navigation Bar</title>
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
</head>
<body class="logo" onload="Sidebar()">
<div class="container" style="max-width: 100%;">
<div class="row" >
<div class="col">
<h5> E-mail= Himanshusingla256#gmail.com</h5>
</div>
<div class="col">
<h5> Contact= 7589832256</h5>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="app.js"></script>
</body>
</html>
Login Index File
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:400,600,700" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="style.css" type="text/css">
<title> Singla Visa Consultancy</title>
</head>
<body class="log">
<div class="container2">
<div class="row">
<h1> Visa Consultancy Software </h1>
</div>
<div class="row1">
<form >
<!-- <div class="form-group"> -->
<label for="exampleInputEmail1" style="color: white;">E-mail:</label>
<input type="text" class="form-control" placeholder="E-mail" id="maile">
<label for="email" class="email" style="color: red;"></label>
<!-- </div> -->
<br>
<!-- <div class="form-group"> -->
<label for="exampleInputPassword1" style="color: white;">Password:</label>
<input type="password" class="form-control" placeholder="password" id="pasw" >
<!-- <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password"></span> -->
<label for="passw" class="password" style="color: red;"></label>
<!-- </div> -->
<br>
<div class="row">
<div style="color: seashell;margin-left: 5% ;">Forget Password?
<br>
<label for="forget" class="forget" style="color: red;"></label>
</div>
</div>
<button type="submit" class="btn btn-success" style="background: transparent;">Login</button>
<br>
<br>
<h6 style="color: white; text-align: right;">Not registered? Create an account</h6>
</form>
</div>
</div>
</body>
<!-- <script src="bootstrap.min.js" type="text/javascript.js"></script> -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="app.js"></script>
</html>[enter image description here][1]
The method document.getElementsByClassName(".home") returns an HTML Collection which don't have an addEventListener method on it, you will need to iterate over each item in the collection and bind it yourself. Also, you don't use the . in the name of the class, so it would be something lke this:
const allElements = document.getElementsByClassName("home"); // <-- No dot in the name
allElements.forEach(home => home.addEventListener('click', () => {
// Do what you want here
window.open("home.html");
})
);
Alternatively, if you know that you will only get one element with that class name or you are only interested in the first element, you can use the querySelector method instead, like so:
document.querySelector(".home").addEventListener('click', () => {
// Do what you want here
window.open("home.html");
});
So I was programming my search bar and I can't quite know why it's not working. I am wanting when a user types "forums" it says a message and when they click okay it sends them to the forums, but I was testing to see if it would display the alert it and I couldnt get it to say anything.
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>website name / slogan</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.min.css" />
</head>
<body>
<div class="row">
<div class="span12">
<form method="get" action="/" class="form-inline" >
<input name="q" class="span5" id="searchBar" type="text" placeholder="Click below on how to use" />
<button type="submit" id="submit" class="btn btn-primary"> <i class="icon-search icon-white"></i></button>
</form>
</div>
</div>
<script type="text/javascript" src="js/bootstrap.js"></script>
</body>
Javascript
function myNavSystem() {
var mySearchBar = document.getElementById('searchBar');
if(mySearchBar = "forums")
document.getElementById('submit');
alert("you have tried accessing forums")
else
alert("You have entered invalid text, try again.")
}
One obvious mistake is that you forgot curly braces in your if / else statement (and semicolons).
if(mySearchBar.value == "forums") {
document.getElementById('submit');
alert("you have tried accessing forums");
} else {
alert("You have entered invalid text, try again.");
}