Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 139713

Can't get input validation Javascript to work

$
0
0

Apologies if this question isn't layed out correctly (my first time using stack overflow). I'm trying to validate if my inputs on a form are filled in when a user presses submit, it alerts the user when the inputs are empty but also when they are not, I'm not sure whats going wrong. Here is my Javascript:

<script>
   function validation() {
     var x = document.forms["bookingForm"]["id"].value;
     if (x == "") {
       alert("Ensure all fileds are filled");
       return false;
     } else {
       sendSMS();
       alert("Success");
       return true;
     }
      }
</script>

Here is a link to an expanded part of the code for reference:https://pastebin.com/Dj5fA3gB


Viewing all articles
Browse latest Browse all 139713

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>