I am trying to add app script to google script but when I am writing the code some times it works and sometimes it gives error I can't find the error tell me what's wrong in this script

  <!--JavaScript at end of body for optimized loading-->
     <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

    var nameBox = document.getElementById("Username");
    var phoneBox = document.getElementById("tel");

    function addRecord(){

    var name = nameBox.value;
    var phone = phoneBox.value;
    if(name.trim().length == 0 || phone.trim().length == 0){

    M.toast({html: 'Invalid Input, Try Again !'});


       var data = {

        name: nameBox.value,
        phone: phoneBox.value



        nameBox.value = "";
        phoneBox.value = "";




0 Answers