How can I configure "Enter key" while sending whatsapp message through HTML form?

Viewed 56

so that user doesn't need to click enter button for sending message fetched from HTML page(form)?

<form onsubmit="gotowhatsapp()">
                    <input type="text" name="username" class="username form-control" placeholder="Name" id="name"
                        required />
                    <input type="email" name="Email" class="username form-control" placeholder="Email" id="email"
                        required />
                    <input type="tel" name="phone" class="username form-control" placeholder="Phone Number"
                        id="phone" pattern="[0-9]{10}"
                        oninvalid="this.setCustomValidity('Please Enter a valid Phone Number')"
                        oninput="this.setCustomValidity('')" required /><input class="btn" type="submit" name="submit" value="Submit" >
                </form> <script>
    function gotowhatsapp() {

        var name = document.getElementById("name").value;
        var phone = document.getElementById("phone").value;
        var email = document.getElementById("email").value;
        
        var url = "https://api.whatsapp.com/send?phone=761xxxxxxx&text="
            + "Name: " + name + "%0a"
            + "Phone: " + phone + "%0a"
            + "Email: " + email + "%0a"
       

        window.open(url, '_blank').focus();//**"here it redirects to whatsapp application but you need to press enter to send messege."**
    }
</script>

Is there any option to use "\n" so that it acts as "Enter key"? because I didn't find any solution to this yet.

0 Answers
Related