Developer forum

Forum » Development » Validating costumer input

Validating costumer input


Reply

Hi


How do I validate the customer input on the page costumer.html?


I want to validate that something has been written in the name, adress and other fields.


Replies

 
Reply

 



Got this from DW - It works fine:


 




function submitForm() {

        if (checkform()){

        document.submitUserData.submit();

        }

}

 

 

function SetSlectedLanguage() {

        var opt = document.submitUserData.EcomOrderCustomerCountry.options;

        for (var i=1;i
               if (opt[i].value == "") {

                       opt[i].selected = true;

               }

        }

 

        opt = document.submitUserData.EcomOrderDeliveryCountry.options;

        for (var i=1;i
               if (opt[i].value == "") {

                       opt[i].selected = true;

               }

        }

}

 

 

function checkform()

{

        if (document.submitUserData.EcomOrderCustomerName.value == '')

        {

               // something is wrong

               alert('Udfyld venligst Navn');

               return false;

        }

        else if (document.submitUserData.EcomOrderCustomerAddress.value == '')

        {

               // something else is wrong

               alert('Udfyld venligst Adresse');

               return false;

        }

        else if (!document.submitUserData.EcomOrderCustomerZip.value.match(/^\d{4}$/))

        {

               // something else is wrong

               alert('Angiv venligst et gyldigt Postnummer');

               document.submitUserData.EcomOrderCustomerZip.focus();

               return false;

        }

        else if (document.submitUserData.EcomOrderCustomerCity.value == '')

        {

               // something else is wrong

               alert('Udfyld venligst By');

               return false;

        }

        else if (document.submitUserData.EcomOrderCustomerPhone.value == '')

        {

               // something else is wrong

               alert('Udfyld venligst Telefonnummer');

               return false;

        }

        else if (!validateEmail(document.submitUserData.EcomOrderCustomerEmail.value))

        {

               // something else is wrong

               alert('Angiv venligst en gyldig e-mailadresse');

               return false;

        }

 

        return true;

}

 
Reply

How do I validate the customer input on the page CartOrderForm.html in the old Shop?




I want to validate that the customer has checked the box for the sales and delievery conditions and if not, to re-load the form with an error message.

 

You must be logged in to post in the forum