Hi to everyone & Ivan!
I’ve got a problem that I’ve been trying to solve…some help pls?
- I’ve created an html input field for data
- I’ve also created a html button
- I’ve inserted the ajax jQuery library ref link
-
I’ve used this script code below to ref that html:
button id= “myButton” & input id= "message"
$("#myButton").click(function() {
var inptxt = $("#message").val();
alert(inptxt);
})
The code calls/invokes the alert when you click the button.
(whether there’s text in the input field or not it pops up an alert.)
Does anyone know?
…but I would like a condition where if there’s no text in the field then the alert will pop up saying “Please enter your name.” before allowing the next click function alert to display with the text imputed…
I spent a lot of time researching/reading and watching the CS50 video again… I tried different if, else conditions, combinations,but I couldn’t get it to work?..help needed?
Thx…