0

How do make this code display an alert when user click submit

<label for="fname">Name</label> <input type="text" id="v" name="firstname" placeholder="Your name.." onkeyup="f()" required> <p id="no"> Check </p> <div id="bb"> </div> <button id="btn1" onclick="f()" disabled>Try it</button> function f() { var i; var a = [ "Q", 1]; var p = document.getElementById("v").value; var c = document.getElementById("btn1"); c.disabled = true; for(var i = 0; i < a.length; i++) { if (a[i] == p) { c.disabled = false; document.getElementById("no").innerHTML = p;

3rd May 2018, 12:55 PM
klisco1
8 ответов
+ 2
Who are you talking to? Tag one of us using the @ symbol followed by one of our names (@name)
3rd May 2018, 11:46 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 2
@Ben Allen (Njinx) Yes, you can do that but you can't use double quotes and this is the reason it isn't working. Instead use single quotes.Try this: <button onClick = "alert('text')">Submit</button>
4th May 2018, 7:30 AM
Jalaj Kumar
Jalaj Kumar - avatar
+ 1
Jalaj Kumar I'm pretty sure you don't even need func(). You can just do onclick="alert("text")"
3rd May 2018, 4:33 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
0
Simply do this: <button onclick = "func()">Submit</button> <script> function func(){ alert("Your text goes here"); } </script> Wasn't it easy to do that!! You can also refer to this code by me: https://code.sololearn.com/WUS6qOHWWyR5/#js
3rd May 2018, 1:03 PM
Jalaj Kumar
Jalaj Kumar - avatar
0
Thanks but That was a different thing
3rd May 2018, 1:08 PM
klisco1
0
Doesn’t work
3rd May 2018, 11:42 PM
klisco1
0
@ben Allen
6th May 2018, 10:36 AM
klisco1
0
I figure it out myself. Thanks guys
6th May 2018, 11:46 AM
klisco1