www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with loading webpages and functions that only allow A-Z characters

  1. #1
    Join Date
    Feb 2012
    Posts
    64

    Help with loading webpages and functions that only allow A-Z characters

    Hi, I was wondering whether anyone could help me.

    1) I would like it so that if all of the validation checks for a Payment form are passed, then the user is redirected to a new page which is called "checkout.html"

    2) I was wondering what the best function would be so that only characters between A-Z can be entered in by the user. I'm sure it would involve regexp of some kind


    Code:
     function ValidatePaymentDetails()
    {
    	var cardnum=document.forms["payment"]["cardnumber"].value;
    	var cardexp=document.forms["payment"]["cardexpirydate"].value;
        var cardsec=document.forms["payment"]["cardsecuritynumber"].value;
    	var href="checkout.html";
    if (((hasWhiteSpace2(cardnum))&&(hasWhiteSpace2(cardexp))&&(hasWhiteSpace2(cardsec))))
    {
    	alert("You have not entered any suitable values for the Card Number, Card Expiry Date or Card Security Number fields. Enter in suitable values, possibly by removing any leading or trailing spaces");
    }
    else if (((cardnum==null||cardnum=="")&&(cardexp==null||cardexp=="") && (cardsec==null||cardsec=="")))
    {
    alert("You have not entered any suitable values for the Card Number, Card Expiry Date or Card Security Number fields. Enter in suitable values.");
    }
    else if ((hasWhiteSpace2(cardnum))&&(hasWhiteSpace2(cardexp)))
    {
    	alert("You have not entered any suitable values for the Card Number or Card Expiry Date fields. Enter in suitable values, possibly by removing any leading or trailing spaces");
    }
    else if ((cardnum==null||cardnum=="")&&(cardexp==null||cardexp==""))
    {
    	alert("You have not entered any suitable values for the Card Number or the Card Expiry fields. Enter in suitable values.");
    }
    else if ((hasWhiteSpace2(cardnum))&&(hasWhiteSpace2(cardsec)))
    {
    	alert("You have not entered any suitable values for the Card Number or Card Security Number fields. Enter in suitable values, possibly by removing any leading or trailing spaces");
    }
    else if((cardnum==null||cardnum=="")&&(cardsec==null||cardsec==""))
    	{
    	alert("You have not entered any suitable values for the Card Number or the Card Security Number fields. Enter in suitable values.");
    }	
    else if ((hasWhiteSpace2(cardexp))&&(hasWhiteSpace2(cardsec)))
    {
    	alert("You have not entered any suitable values for the Card Expiry Date or Card Security Number fields. Enter in suitable values, possibly by removing any leading or trailing spaces");
    }				
    else if((cardexp==null||cardexp=="")&&(cardsec==null||cardsec==""))
    	{
    	alert("You have not entered any suitable values for the Card Expiry Date or the Card Security Number fields. Enter in suitable values.");
    }
    else if (hasWhiteSpace2(cardnum))
    {
    	alert("You have not entered in a suitable value for the Card Number field. Enter in a suitable value, possibly by removing any leading or trailing spaces");
    }
    else if(cardnum==null|| cardnum=="")
    {
    		alert("You have not entered a suitable value for the Card Number field. Enter in a suitable value.");
    }
    else if (hasWhiteSpace2(cardexp))
    {
    	alert("You have not entered in a suitable value for the Card Expiry Date field. Enter in a suitable value, possibly by removing any leading or trailing spaces");
    }
    else if(cardexp==null|| cardexp=="")
    {
    	alert("You have not entered a suitable value for the Card Expiry Date field. Enter in a suitable value.");
    }
    else if (hasWhiteSpace2(cardsec))
    {
    	alert("You have not entered a suitable value for the Card Security Number field. Enter in a suitable value, possibly by removing any leading or trailing spaces");
    }
    else if(cardsec==null|| cardsec=="")
    {
    	alert("You have not entered a suitable value for the Card Security Number field. Enter in a suitable value.");
    }
    else if (checknumber(cardnum)==false)
    {
    	alert("You have not entered in a valid Card Number in the Card Number field. Make sure that it is in the 0000-0000-0000-0000 format and remove any leading or trailing spaces. Enter in a suitable value.");
    }
    else if (checksecnumber(cardsec)==false)
    {
    	alert("You have not entered in a valid Card Security Number in the Card Security Number field. Make sure it is in the 000 format. Enter in a suitable value.");
    }
    else if (compareDate(cardexp)==true)
    {
    	return true;
    }
    
    else
    {
    //CODE FOR LOADING NEW PAGE WILL GO HERE
    }
    }
    Any help is appreciated

  2. #2
    Join Date
    Feb 2012
    Posts
    64
    Anybody willing/able to help me?

    Any help is appreciated

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles