Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <link rel="stylesheet" type="text/css" href="css/buildstyle.css" />
- <title>Part 1 Form</title>
- <!--<script src="js/OrderProcessingScripts.js" />-->
- <script>
- function submit(){
- var part1=submitPart1();
- var part2=submitPart2();
- var part3=submitPart3();
- var part4=submitPart4();
- if(part1){
- if(part2){
- if(part3){
- if(part4){
- window.location="Part2Receipt.html?"+document.getElementById("businessName").value+"?"+document.getElementById("firstName").value+"_"+document.getElementById("lastName").value+"?"+document.getElementById("pricing").value;
- }
- }
- }
- }
- }
- function submitPart1(){
- var pass=true;
- var firstName=document.getElementById("firstName").value;
- var lastName=document.getElementById("lastName").value;
- var contactAddress=document.getElementById("contactAddress").value;
- var contactCity=document.getElementById("contactCity").value;
- var contactState=document.getElementById("contactState").value;
- var contactZip=document.getElementById("contactZip").value;
- var contactPhone=document.getElementById("contactPhone").value;
- var contactEmail=document.getElementById("contactEmail").value;
- //check everything
- if(firstName==""){ //check first name
- pass=false;
- document.getElementById("divFirstName").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divFirstName").style.color="#000000";
- }
- if(lastName==""){ //check last name
- pass=false;
- document.getElementById("divLastName").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divLastName").style.color="#000000";
- }
- if(contactAddress==""){ //check contact address
- pass=false;
- document.getElementById("divContactAddress").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divContactAddress").style.color="#000000";
- }
- if(contactCity==""){ //check contact city
- pass=false;
- document.getElementById("divContactCity").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divContactCity").style.color="#000000";
- }
- if(contactState==""){ //check contact state
- pass=false;
- document.getElementById("divContactState").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divContactState").style.color="#000000";
- }
- if(contactZip==""){ //check contact zip
- pass=false;
- document.getElementById("divContactZip").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divContactZip").style.color="#000000";
- }
- //check that the phone has the correct number of digits and hypens
- var phoneFail=false;
- //don't judge me for this horribe mess, for some reason it won't let me use || so I had to nest them
- if(contactPhone.length==12){
- if(contactPhone.charAt(3)=='-' && contactPhone.charAt(7)=='-'){
- for(var counter=0; counter<contactPhone.length; counter++){
- var currentNumber=contactPhone.charAt(counter);
- if(!(counter==3)){
- if(!(counter==7)){
- if(!(currentNumber=='0'))
- if(!(currentNumber=='1'))
- if(!(currentNumber=='2'))
- if(!(currentNumber=='3'))
- if(!(currentNumber=='4'))
- if(!(currentNumber=='5'))
- if(!(currentNumber=='6'))
- if(!(currentNumber=='7'))
- if(!(currentNumber=='8'))
- if(!(currentNumber=='9'))
- phoneFail=true;
- }
- }
- }
- }
- else phoneFail=true;
- }
- else phoneFail=true;
- if(phoneFail){
- pass=false;
- document.getElementById("divContactPhone").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divContactPhone").style.color="#000000";
- }
- //check that the email has an @ sign and a valid extension
- var emailFail=false;
- var atPos=-1;
- var dotPos=-1;
- for(var counter=0; counter<contactEmail.length; counter++){
- if(contactEmail.charAt(counter)=='@'){
- atPos=counter;
- }
- if(contactEmail.charAt(counter)=='.'){
- dotPos=counter;
- }
- }
- if(atPos<1){
- emailFail=true;
- }
- if(dotPos>contactEmail.length-3){
- emailFail=true;
- }
- if(dotPos-atPos<3){
- emailFail=true;
- }
- if(emailFail){
- pass=false;
- document.getElementById("divContactEmail").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divContactEmail").style.color="#000000";
- }
- //handle everything being filled/correct
- if(pass){
- //make all the text fields read-only and gray them out
- document.getElementById("firstName").readOnly=true;
- document.getElementById("firstName").style.backgroundColor="#BBBBBB";
- document.getElementById("lastName").readOnly=true;
- document.getElementById("lastName").style.backgroundColor="#BBBBBB";
- document.getElementById("contactAddress").readOnly=true;
- document.getElementById("contactAddress").style.backgroundColor="#BBBBBB";
- document.getElementById("contactCity").readOnly=true;
- document.getElementById("contactCity").style.backgroundColor="#BBBBBB";
- document.getElementById("contactState").readOnly=true;
- document.getElementById("contactState").style.backgroundColor="#BBBBBB";
- document.getElementById("contactZip").readOnly=true;
- document.getElementById("contactZip").style.backgroundColor="#BBBBBB";
- document.getElementById("contactPhone").readOnly=true;
- document.getElementById("contactPhone").style.backgroundColor="#BBBBBB";
- document.getElementById("contactEmail").readOnly=true;
- document.getElementById("contactEmail").style.backgroundColor="#BBBBBB";
- }
- if(pass){
- return true;
- }
- else{
- return false;
- }
- }
- function reuseInfo(){
- document.getElementById("businessAddress").value=document.getElementById("contactAddress").value;
- document.getElementById("businessCity").value=document.getElementById("contactCity").value;
- document.getElementById("businessState").value=document.getElementById("contactState").value;
- document.getElementById("businessZip").value=document.getElementById("contactZip").value;
- }
- function submitPart2(){
- var pass=true;
- var businessName=document.getElementById("businessName").value;
- var businessAddress=document.getElementById("businessAddress").value;
- var businessCity=document.getElementById("businessCity").value;
- var businessState=document.getElementById("businessState").value;
- var businessZip=document.getElementById("businessZip").value;
- var businessPhone=document.getElementById("businessPhone").value;
- var businessWebsite=document.getElementById("businessWebsite").value;
- //check everything
- if(businessName==""){ //check business name
- pass=false;
- document.getElementById("divBusinessName").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divBusinessName").style.color="#000000";
- }
- if(businessAddress==""){ //check business address
- pass=false;
- document.getElementById("divBusinessAddress").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divBusinessAddress").style.color="#000000";
- }
- if(businessCity==""){ //check business city
- pass=false;
- document.getElementById("divBusinessCity").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divBusinessCity").style.color="#000000";
- }
- if(businessState==""){ //check business state
- pass=false;
- document.getElementById("divBusinessState").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divBusinessState").style.color="#000000";
- }
- if(businessZip==""){ //check business zip
- pass=false;
- document.getElementById("divBusinessZip").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divBusinessZip").style.color="#000000";
- }
- if(businessWebsite==""){ //check business website
- pass=false;
- document.getElementById("divBusinessWebsite").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divBusinessWebsite").style.color="#000000";
- }
- //check that the phone has the correct number of digits and hypens
- var phoneFail=false;
- //don't judge me for this horribe mess, for some reason it won't let me use || so I had to nest them
- if(businessPhone.length==12){
- if(businessPhone.charAt(3)=='-' && businessPhone.charAt(7)=='-'){
- for(var counter=0; counter<businessPhone.length; counter++){
- var currentNumber=businessPhone.charAt(counter);
- if(!(counter==3)){
- if(!(counter==7)){
- if(!(currentNumber=='0'))
- if(!(currentNumber=='1'))
- if(!(currentNumber=='2'))
- if(!(currentNumber=='3'))
- if(!(currentNumber=='4'))
- if(!(currentNumber=='5'))
- if(!(currentNumber=='6'))
- if(!(currentNumber=='7'))
- if(!(currentNumber=='8'))
- if(!(currentNumber=='9'))
- phoneFail=true;
- }
- }
- }
- }
- else phoneFail=true;
- }
- else phoneFail=true;
- if(phoneFail){
- pass=false;
- document.getElementById("divBusinessPhone").style.color="#FF0000";
- }
- else{
- pass=true;
- document.getElementById("divBusinessPhone").style.color="#000000";
- }
- //handle everything being filled/correct
- if(pass){
- //make all the text fields read-only and gray them out
- document.getElementById("businessName").readOnly=true;
- document.getElementById("businessName").style.backgroundColor="#BBBBBB";
- document.getElementById("businessAddress").readOnly=true;
- document.getElementById("businessAddress").style.backgroundColor="#BBBBBB";
- document.getElementById("businessCity").readOnly=true;
- document.getElementById("businessCity").style.backgroundColor="#BBBBBB";
- document.getElementById("businessState").readOnly=true;
- document.getElementById("businessState").style.backgroundColor="#BBBBBB";
- document.getElementById("businessZip").readOnly=true;
- document.getElementById("businessZip").style.backgroundColor="#BBBBBB";
- document.getElementById("businessPhone").readOnly=true;
- document.getElementById("businessPhone").style.backgroundColor="#BBBBBB";
- document.getElementById("businessWebsite").readOnly=true;
- document.getElementById("businessWebsite").style.backgroundColor="#BBBBBB";
- }
- if(pass){
- return true;
- }
- else{
- return false;
- }
- }
- function switchField(input){
- var field=document.getElementById(input).value;
- if(field=="1"){
- document.getElementById(input).value="0";
- }
- else{
- document.getElementById(input).value="1";
- }
- updatePrice();
- }
- function updatePrice(){
- var newPrice=0;
- document.getElementById("pricing").value=0;
- if(document.getElementById("hiddenWeb").value=="1"){
- newPrice+=5;
- }
- if(document.getElementById("hiddenEmail").value=="1"){
- newPrice+=6;
- }
- if(document.getElementById("hiddenFacebook").value=="1"){
- newPrice+=7;
- }
- if(document.getElementById("hiddenLinkedIn").value=="1"){
- newPrice+=8;
- }
- if(document.getElementById("hiddenTwitter").value=="1"){
- newPrice+=9;
- }
- document.getElementById("pricing").value=newPrice;
- }
- function emptyInfo(){
- document.getElementById("businessAddress").value="";
- document.getElementById("businessCity").value="";
- document.getElementById("businessState").value="";
- document.getElementById("businessZip").value="";
- }
- function submitPart4(){
- var month=document.getElementById("expireMonth").options[document.getElementById("expireMonth").selectedIndex].value;
- var day=document.getElementById("expireDay").options[document.getElementById("expireDay").selectedIndex].value;
- var year=document.getElementById("expireYear").options[document.getElementById("expireYear").selectedIndex].value;
- var cardNumber=document.getElementById("cardNumber").value;
- var cardIssuer=document.getElementById("cardIssuer").value;
- //I'm not sure what kind of input you want for CCverify, the assignment doesn't say
- //so I'm just putting in all the information as seperate variables
- /*
- var invalid=CCverify(cardIssuer, cardNumber, month, day, year);
- if(invalid){
- document.getElementById("cardNumber").style.color="#FF0000";
- return false;
- }
- else{
- document.getElementById("cardNumber").style.color="#000000";
- return true;
- }
- */
- return true;
- }
- function submitPart3(){
- if(document.getElementById("pricing").value==0){
- document.getElementById("services").style.color="#FF0000";
- return false;
- }
- else{
- document.getElementById("services").style.color="#000000";
- return true;
- }
- }
- </script>
- </head>
- <body>
- <form>
- <input type="hidden" id="hiddenWeb" value="" />
- <input type="hidden" id="hiddenEmail" value="" />
- <input type="hidden" id="hiddenFacebook" value="" />
- <input type="hidden" id="hiddenLinkedIn" value="" />
- <input type="hidden" id="hiddenTwitter" value="" />
- </form>
- <div id="mainForm"><form>
- <div id="divContact">
- <!--first name, last name, street address, city, state, zip, phone and email-->
- <div id="divFirstName"> First Name: <input type="text" id="firstName" value="" /> </div>
- <div id="divLastName"> Last Name: <input type="text" id="lastName" value="" /> </div>
- <div id="divContactAddress"> Address: <input type="text" id="contactAddress" value="" /> </div>
- <div id="divContactCity"> City: <input type="text" id="contactCity" value="" /> </div>
- <div id="divContactState"> State: <input type="text" id="contactState" value="" /> </div>
- <div id="divContactZip"> Zip Code: <input type="text" id="contactZip" value="" /> </div>
- <div id="divContactPhone"> Phone: <input type="text" id="contactPhone" value="" /> </div>
- <div id="divContactEmail"> Email: <input type="text" id="contactEmail" value="" /> </div>
- </div> <br />
- <div id="divBusiness">
- <input type="checkbox" name="useInfo" id="useInfo" value="reuse" onClick="if (this.checked) {reuseInfo()} else{emptyInfo()}" />Use contact information?
- <div id="divBusinessName"> Business Name: <input type="text" id="businessName" value="" /> </div>
- <div id="divBusinessAddress">Business Address: <input type="text" id="businessAddress" value="" /></div>
- <div id="divBusinessCity"> Business City: <input type="text" id="businessCity" value="" /> </div>
- <div id="divBusinessState"> Business State: <input type="text" id="businessState" value="" /> </div>
- <div id="divBusinessZip"> Business Zip Code: <input type="text" id="businessZip" value="" /> </div>
- <div id="divBusinessPhone"> Business Phone: <input type="text" id="businessPhone" value="" /> </div>
- <div id="divBusinessWebsite">Business Website: <input type="text" id="businessWebsite" value="" /></div>
- </div> <br />
- <div id="services">
- Services Available: <br />
- <input id="web" type="image" src="img/Computer-icon.png" width="50" onclick="switchField('hiddenWeb'); return false;"/><span id="webDev"> Web Development - $5</span><br />
- <input id="email" type="image" src="img/Email-icon.png" width="50" onclick="switchField('hiddenEmail'); return false;"/><span id="emailMarketing"> Email Marketing - $6</span><br />
- <input id="facebook" type="image" src="img/Facebook-icon.png" width="50" onclick="switchField('hiddenFacebook'); return false;"/><span id="facebookIntegration"> Facebook Integration - $7</span><br />
- <input id="linkedin" type="image" src="img/LinkedIn-icon.png" width="50" onclick="switchField('hiddenLinkedIn'); return false;"/><span id="linkedinListings"> LinkedIn Listings - $8</span><br />
- <input id="twitter" type="image" src="img/Twitter-icon.png" width="50" onclick="switchField('hiddenTwitter'); return false;"/><span id="twitterBranding"> Twitter Branding - $9</span><br /><br />
- Price (USD): <input style="background-color:#BBBBBB" type="text" id="pricing" value="0" />
- </div>
- <br />
- <div id="creditCardInfo">
- Credit Card Issuer:
- <select id="cardIssuer">
- <option value="Discover">Discover</option>
- <option value="AmericanExpress">American Express</option>
- <option value="Visa">Visa</option>
- <option value="Mastercard">Mastercard</option>
- </select> <br />
- Credit Card Number:
- <input id="cardNumber" type="text" value="" /> <br />
- Exp.:
- <select id="expireMonth">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- </select>
- /
- <select id="expireDay">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- <option value="24">24</option>
- <option value="25">25</option>
- <option value="26">26</option>
- <option value="27">27</option>
- <option value="28">28</option>
- <option value="29">29</option>
- <option value="30">30</option>
- <option value="31">31</option>
- </select>
- /
- <select id="expireYear">
- <option value="2013">2013</option>
- <option value="2014">2014</option>
- <option value="2015">2015</option>
- <option value="2016">2016</option>
- <option value="2017">2017</option>
- <option value="2018">2018</option>
- </select>
- </div>
- </form>
- <br />
- <button onclick="submit()">Submit Information</button></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement