How to add javascript into php?

Here is my js code

<script>
function myform() {
    var n = document.getElementById("name").value;

    if (n == "") {
        document.getElementById("username").innerHTML = "Please enter your name";
        return false;
    }
    if (!isNaN(n)) {
        document.getElementById("username").innerHTML = "Please enter valid name";
        return false;
    }
}
</script>

How to write this js code into php

m trying all code in echo but not working plz help

after php echo using

    echo'<script>
function myform() {
    var n = document.getElementById("name").value;

    if (n == "") {
        document.getElementById("username").innerHTML = "Please enter your name";
        return false;
    }
    if (!isNaN(n)) {
        document.getElementById("username").innerHTML = "Please enter valid name";
        return false;
    }
}
</script>';

thankyou



from Recent Questions - Stack Overflow https://ift.tt/3iYHgzu
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation