After hitting the "PayNow" button the page refreshes and the console log does not open with payment sent or erros

  html, javascript

First here is my HTML Code: https://pastebin.com/Rxbn6092

<!-- a submit button using the paynow image rather than text --> 
            <br><input type="image" src="images/PayNow.png" onsubmit="validateForm()" class="output"></br>  
            <!-- <button type="submit" onsubmit="validateForm" name="PayNow" value="PayNow"><img 

(sample of the html code, I have to use this image and I think it’s messing up the sumbit form)

Next here is the Javascrpt code: https://pastebin.com/4UcH8wR8 (This is where I believe the problems is, but not sure. Been trying to figure this out the last couple of days and still not sure why I don’t get an actually output.

function validateForm()

{

// we need to get all of the references of dom objects in vars 
var cvc = document.getElementByld("cvc");
var zip = document.getElementByld("Zip");
var cc = document.getElementByld("CreditCard");
var date = document.getElementByld("Date");
var state = document.querySelector("#State");
var email = document.getElementByld("Email");

// check all details entered in the form, is the cvc 3 digits and is the zip 5 digits. 
if (validateControl(cvc, "cvc", 3) && validateControl(zip, "Zip", 5) && validateCreditCard(cc.value) && validateDate(date.value) && validateEmail(email.value) && validateState(state.selectedIndex)) 
{
    
    console.log("Payment Submitted");
    document.querySelector('.output').textContent = "Payment Sent";
    return true;
}
    document.querySelector('.output').textContent = "Payment Failed";
    return false;

}

(From the js code, I think this function is also the problem, but I’m not sure man. Any help and I’d appreciate it!

So this is suppose to be a baic credit card processing form, but I’m somehow messing it up. (still new to html) After hitting the PayNow button I would like the page to confirm payment, and if you enter the wrong zip/cvc there should be an error message, but it does not work. Any ideas, I’d love any help thanks in advance!

Ex of the console box output wanted: https://gyazo.com/bd209c49c037681c2ab93118e77a9ee2
This is example is kindof poor, since the paynow is not a button, but an image that is required to use, any way to fix my issues?

Source: Ask Javascript Questions

LEAVE A COMMENT