Hi I am making a log in page
-that takes in the username + processes it and if right then redirects to home page(currently is giving me the error message shown below when run
-gives alerts/warnings with number of chances left(when 0 doesn't do much but will make it redirect to empty page)
-writes in console "Hello "+username just for testing that it works
and shows this error in intellIJ IDE:
and the code for the file is shown below please let me know why it is not working:
import React, {useState} from 'react';
import "./Login.css"
//allows page navigation
import { useNavigate } from "react-router-dom";
function Login() {
//navigate constant is used to redirect to another page
const navigate = useNavigate();
return (
<div className={"form-inner"}>
<form>
<h2>Login to Study Skills</h2>
<div className={"form-group"}>
<label htmlFor={"name"}><b>Username:</b></label>
<input type={"text"} id="myText" placeholder={"Enter Username"} name={"username"} required/>
<select>
<option>Student</option>
<option>Tutor</option>
</select>
</div>
<button id="myButton"> SIGN IN </button>
</form>
<script>
function authenticate(a){
var t1 = false;
var t2 = false;
var b = c.search("[a-z][a-z][0-9][0-9][0-9][0-9][0-9]")
if(b == 0){
t1 = true}
if(a.length == 7){
t2 = true}
return t1&&t2}
var n = 3;
document.getElementById("myButton").onclick = function(){
var myName = document.getElementById("myText").value;
if(authenticate(myName)){
() => navigate("/website")
console.log("welcome "+myName)
}
else if(n == 0){
alert("no more log-ins")
}
else{
alert("you have "+n+" chances to log-in again")
n--
}
}
</script>
</div>
)
}
export default Login;
Thanks a lot for any help as this has got me stuck for a few hours now and I can't do it another way