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;
8 Respostas
+ 2
Who are you talking to? Tag one of us using the @ symbol followed by one of our names (@name)
+ 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>
+ 1
Jalaj Kumar I'm pretty sure you don't even need func(). You can just do onclick="alert("text")"
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
0
Thanks but That was a different thing
0
Doesn’t work
0
@ben Allen
0
I figure it out myself. Thanks guys