Search code examples
jqueryif-statementtextbox

If blank text is in textbox then blank action


Here's an example of what I'm trying to do.

if 
    $("#textinput").val("evil");
then
    alert("Watch your language!");
end if

Solution

  • This line of code will set the value of the input

    $("#textinput").val("evil");
    

    You said you wanted to test the current text

    if ($("#textinput").val() === "evil")
    {
        alert("Watch your language!");
    }