Jump to content

danjapro

Members
  • Content count

    75
  • Joined

  • Last visited

Community Reputation

0 Neutral

About danjapro

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  1. danjapro

    Can someone assist with this foreach loop?

    I was able to Get back the Array, but when the Second email kicks-off, still returning the same tracking number from the array and not going to the next(). Can someone tell me if there is a way to if check current(), then go to next() if (!$isOrderShipped) { return false;} else { if (count($items) > 1 && count($trackingNumbers) >= 1) { echo "You may receive multiple shipments and emails. The tracking number for this shipment is " . $displayShippingMethod . " # " . next($trackingInfoInEmail); next($trackingInfoInEmail); } else if(count($items) == 1) { if (count($trackingNumbers) == 1) { echo "The tracking number for this shipment is " . $displayShippingMethod . " # " . next($trackingInfoInEmail); next($trackingInfoInEmail); } else if (count($trackingNumbers) > 1){ echo "You may receive multiple shipments and emails. The tracking number for this shipment is " . $displayShippingMethod . " # " . next($trackingInfoInEmail); next($trackingInfoInEmail); } else if(count($trackingNumbers)==0){ echo "Your Order has been Shipped with" . $displayShippingMethod; } } else { echo "Your Order has been Shipped with" . $displayShippingMethod; }}
  2. danjapro

    Can someone assist with this foreach loop?

    $i was to loop thru ea trackin# to count each one. But I just need it to get each 1 tracking per ea email sent. not all tracking at same time in same email. thru an array,. dont need it that way
  3. danjapro

    Can someone assist with this foreach loop?

    Struggling with this piece of code: Still getting duplicate Tracking #s: $isOrderShipped = $adminHelper->getIsOrderShipped($_order->getId()); // Is oorder shipped or not $items = $_order->getAllVisibleItems(); $trackingNumbers = []; $trackNo = $adminHelper->getOrderTrackingNo($_order->getId()); $trackNos = $adminHelper->getOrderTrackingNo($_order->getTrackingNumber()); //$trackNos = explode(",", $trackNo); if (count($trackNos)) { for ($i=0; $i< count($trackNos); $i++) { $trackingURL = $adminHelper->getTrackingUrl(strtolower($_order->getShippingDescription()), $trackNo); $trackingNumbers[] = array("track_no" => $trackNo, "url" => $trackingURL); } } $trackingInfoInEmail = []; if (count($trackingNumbers) > 0) { //for ($i=0; $i < count($trackingNumbers); $i++) { $trackingInfoInEmail[] = "<a href='" . $trackingNumbers[$i]['url'] . "' target='_blank'>" . $trackingNumbers[$i]['track_no'] . "</a>"; //} } $displayShippingMethod = $adminHelper->getTrackingTextInEmail($_order->getShippingDescription()); //Shipping Method Name if (!$isOrderShipped) { return false; } else { $i = 0; if (count($items) > 1) { echo "You may receive multiple shipments and emails."; foreach($items as $item) { $i++; echo "The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); } } else { echo "The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); } }
  4. danjapro

    Can someone assist with this foreach loop?

    I am having a hard time with this piece of code. Can you help me please. It still return, duplicate. Tracking No#s. $isOrderShipped = $adminHelper->getIsOrderShipped($_order->getId()); // Is oorder shipped or not$items = $_order->getAllVisibleItems();$trackingNumbers = [];$trackNo = $adminHelper->getOrderTrackingNo($_order->getId());$trackNos = explode(",", $trackNo);if (count($trackNos)) { for ($i=0; $i< count($trackNos); $i++) { $trackingURL = $adminHelper->getTrackingUrl(strtolower($_order->getShippingDescription()), $trackNo); $trackingNumbers[] = array("track_no" => $trackNo, "url" => $trackingURL); }}$trackingInfoInEmail = [];if (count($trackingNumbers) > 0) { for ($i=0; $i < count($trackingNumbers); $i++) { $trackingInfoInEmail[] = "<a href='" . $trackingNumbers[$i]['url'] . "' target='_blank'>" . $trackingNumbers[$i]['track_no'] . "</a>"; }}$displayShippingMethod = $adminHelper->getTrackingTextInEmail($_order->getShippingDescription()); //Shipping Method Nameif (!$isOrderShipped) { return false;} else { if (count($items) > 1) { echo "You may receive multiple shipments and emails. The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); } else { echo "The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); }}
  5. danjapro

    Can someone assist with this foreach loop?

    I changed this, it works to a degree. Now it is returning duplicated tracking numbers and each tracking number. I need help, just get each one tracking number seperate. $isOrderShipped = $adminHelper->getIsOrderShipped($_order->getId()); // Is oorder shipped or not $items = $_order->getAllVisibleItems(); $trackingNumbers = []; $trackNo = $adminHelper->getOrderTrackingNo($_order->getId()); $trackNos = explode(",", $trackNo); if (count($trackNos)) { for ($i=0; $i< count($trackNos); $i++) { $trackingURL = $adminHelper->getTrackingUrl(strtolower($_order->getShippingDescription()), $trackNo); $trackingNumbers[] = array("track_no" => $trackNo, "url" => $trackingURL); } } $trackingInfoInEmail = []; if (count($trackingNumbers) > ) { for ($i=0; $i < count($trackingNumbers); $i++) { $trackingInfoInEmail[] = "<a href='" . $trackingNumbers[$i]['url'] . "' target='_blank'>" . $trackingNumbers[$i]['track_no'] . "</a>"; } } $displayShippingMethod = $adminHelper->getTrackingTextInEmail($_order->getShippingDescription()); //Shipping Method Name if (!$isOrderShipped) { return false; } else { if (count($items) > 1) { echo "You may receive multiple shipments and emails. The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); } else { echo "The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); } }
  6. danjapro

    Can someone assist with this foreach loop?

    IT worked before. This is the Code base that is causing issues: $trackingInfoInEmail = [];$i = 0;if (count($trackingNumbers) > 1) { foreach($trackingNumbers as $trackingNumber) { $i++; $trackingInfoInEmail = "<a href='" . $trackingNumber[$i]['url'] . "' target='_blank'>" . $trackingNumber[$i]['track_no'] . "</a>"; } }else{ $trackingInfoInEmail = "<a href='" . $trackingNumber[$i]['url'] . "' target='_blank'>" . $trackingNumber[$i]['track_no'] . "</a>"; }
  7. All I am Trying to do is Loop thru my Array fo results and out each one seperate if there is more than 1 data point: Trying to display each of tracking # as separate line: getIsOrderShipped($_order-&gt;getId()); // Is oorder shipped or not ``` $items = $_order->getAllVisibleItems(); $trackingNumbers = []; $trackNo = $adminHelper->getOrderTrackingNo($_order->getId()); $trackNos = explode(",", $trackNo); if (count($trackNos)) { for ($i=0; $i< count($trackNos); $i++) { $trackingURL = $adminHelper->getTrackingUrl(strtolower($_order->getShippingDescription()), $trackNo); $trackingNumbers[] = array("track_no" => $trackNo, "url" => $trackingURL); } } $trackingInfoInEmail = []; $i = 0; if (count($trackingNumbers) > 1) { foreach($trackingNumbers as $trackingNumber) { $i++; $trackingInfoInEmail[] = "<a href='" . $trackingNumber[$i]['url'] . "' target='_blank'>" . $trackingNumber[$i]['track_no'] . "</a>"; return false; } }else{ $trackingInfoInEmail[] = "<a href='" . $trackingNumbers[]['url'] . "' target='_blank'>" . $trackingNumbers[]['track_no'] . "</a>"; } $displayShippingMethod = $adminHelper->getTrackingTextInEmail($_order->getShippingDescription()); //Shipping Method Name if (!$isOrderShipped) { return false; } else { if (count($items) > 0) { echo "You may receive multiple shipments and emails. The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); } else { echo "The tracking number for this shipment is " . $displayShippingMethod . " #&nbsp;" . implode(',', $trackingInfoInEmail); } } ```
  8. danjapro

    Read JSON instead of XML, need some HELP

    That worked.. I had to make few addiontal changes for params, but otherwise worked!!!
  9. I need some Help, I need to re-write my code slightly to read JSON files with Key:Value that there for VML. I just need to read json files instead of reading XML files. Can someone assist, I think it i simple adjustment, I am having hard time. /** * Function install * @param ModuleDataSetupInterface $setup * @param ModuleContextInterface $context * @return void */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $reflector = new \ReflectionClass('Incomm\Cms\Setup\UpgradeData'); $reflector->getFileName(); $contentDirectory = dirname($reflector->getFilename()) . "/../Content/"; $cmsBlocksFiles = glob("{$contentDirectory}Blocks/*xml"); $cmsPagesFiles = glob("{$contentDirectory}Pages/*xml"); $homePageFiles = glob("{$contentDirectory}Homepage/*xml"); /* CMS Blocks */ foreach ($cmsBlocksFiles as $file) { $xml = simplexml_load_file($file, "SimpleXMLElement", LIBXML_NOCDATA); $json = json_encode($xml); $data = json_decode($json, TRUE); unset($data["version"]); $tmpBlock = $this->blockFactory->create(['data' => $data]); $this->blockRepository->save($tmpBlock); } /* CMS Pages */ foreach ($cmsPagesFiles as $file) { $xml = simplexml_load_file($file, "SimpleXMLElement", LIBXML_NOCDATA); $json = json_encode($xml); $data = json_decode($json, TRUE); $page = $this->pageFactory->create(); $page->setTitle($data['title']) ->setIdentifier($data['identifier']) ->setIsActive(true) ->setPageLayout($data['page_layout']) ->setStores(array(0)) ->setContent($data['content']) ->save(); } /* Home page */ $newPage = $this->pageFactory->create()->load( 'home', 'identifier' ); if ($newPage->getId()) { foreach ($homePageFiles as $file) { $xml = simplexml_load_file($file, "SimpleXMLElement", LIBXML_NOCDATA); $json = json_encode($xml); $data = json_decode($json, TRUE); $newPage->setContent($data["content"]); $newPage->save(); } } $setup->endSetup(); } }
  10. We are getting back each error message, but it only outputs the last error message. how can we append each error message to the DIV Here is the code that loops thru each error message if(data.length > 0) { $.each(data, function(error_code, message ) { if(errorCode == $.trim(message.error_code) && errorCode != -1 ){ error_message = message.message; return false; } }); } Here is the code that outputs the error message in a drop down. PLEASE ANY HELP if(BoltNotify === true && multipleNotice === true){ //var error_message += error_message; var spanerrorgen = $('.error.message').contents().find('h4').html(error_message); var appenderrorgen = $('.error.message').contents().find('h4'); $.each(data, function($fieldref) { $(spanerrorgen).append(spanerrorgen); }); VanillaReload.notify.showNotification(".error"); }
  11. danjapro

    Ajax failing with 406

    Please help with this, it not going to the .html controller and returing the values need, it captures the email form values, bu then fails with a 406 error. Please help $('#newsletter').submit(function() { //E-mail is passed var values = $(this).serialize(); var formRef = $('form').attr('id'); var dataString = JSON.stringify(values); //var values = $("#newsletter_email").val(); if($('#newsletter_tc_check').is(':checked')){ $.ajax({ type: 'POST', url: "./saveNewsletterSignupEmailPost.html", dataType: 'json', data: dataString, contentType: 'application/json', mimeType: 'application/json', success: function(data) { var result = $.parseJSON(data); if(result.form == formRef){ $('.success.message').contents().find('h4').text(success.text()); VanillaReload.notify.showNotification("success"); $("#newsletter_email").val(""); }else{ $('.error.message').contents().find('h4').text(error.text()); VanillaReload.notify.showNotification(".error"); } } }); return false; }else{ $('.error.message').contents().find('h4').text(error.text()); vanillaeGift.notify.showNotification(".error"); } return false; });
  12. danjapro

    Help with append Loop

    Trying to simply append each error message into the error.message div. We can get only one of the error messages at time to display in notification div. We just want each field with error to display in notification div. Can anyone give some direction, we mssing: Error Message loop if((data.row_id).length > 0) { $.each(data, function(error_code, message ) { if(errorCode == $.trim(data.error_code) && errorCode != -1 ){ error_message = data.message; return false; } }); } Print out Error Message(display) var spanerrorgen = $('.error.message').contents().find('h4').html(error_message); var appenderrorgen = $('.error.message').contents().find('h4'); $($fieldref).each(function(){ $(spanerrorgen).append(appenderrorgen); }); errorFields.notify.showNotification(".error");
  13. We are trying to get progress bar to place active class on the current page it one based on variable being set on page called "page", also the page is written into the <body class="page"> tag, once it is loading the page. It is not working as we need can anyone, help us with script below to set progress bar to do prev and next????? So variable is: var page = "refundstep1"; Body Class tage looks like: <body class="refunStep 1 main-layout"> Progress bar is: <div class="tabContent progress-bar hidden-phone"> <div class="step active"> <h2>Step 1: Enter your Pin</h2> </div> <div class="step inactive"> <h2>Step 2: Tell us your address</h2> </div> <div class="step inactive"> <h2>Step 3: Confirm Your Details</h2> </div> </div> Code to actual set the other list next as class="inactive", list passed or compelted as class="active done", Current page as class="active" var progressClass = $('.progress-bar div.step'); $(progressClass).addClass(function(index, activeClass) { var activeClass = 'done'; var activePage = 'active'; alert(page); var currentPage = page; var pageClass = $('body').hasClass(page); console.log(pageClass); if(pageClass === true) { progressClass.addClass(activePage); progressClass.prevAll().addClass(activeClass); //To select all next elements of `.progressClass` element: progressClass.nextAll().addClass(nopageClass); } return nopageClass; });
  14. danjapro

    Help with Getting Error Message

    CroNix, Possible you could take a look at entire valdiation script we posted in previous message. Still need help with this.
  15. danjapro

    Help with Getting Error Message

    Cronix, got another issue need some help with too: Both issues: Error message are not coming back as needed, geting last error message only for each field validation error. & Also, another issue here once you enter into the _getErrorMessage function, It wil not allow you to submit the form. I think I need some help with that to. Can you please test locally on your PC and get it working Need: Get correct error message Submit form once fields are good and no errors Attached my entire validations.js file, take look and let me know. what we doing wrong here. Copy entire file and then you can paste into text editor and see complete flow. // JavaScript Document// Pop-up notification // Multiple Notification can be set here also // Change both to 1 and then they are enabled // See Lines (), for the functionality // MG. Added feature 07/2014 var BoltNotify = true; var multipleNotice = false; var validatejson = { formats: { //email: /^\w+@[^\s\.]+\.[^\s\.]+[^\s]*[^\s\.]*$/, name: /^[a-zA-Z ]*$/, email: /^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/, ip: /^(\d{1,3}\.){3}\d{1,3}$/, date: /^\d{2}[- \/.]\d{2}[- \/.]\d{4}$/, /* ^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$ */ datetime: /^\d{2}[- \/.]\d{2}[- \/.]\d{4}\s?\d{2}[- :.]\d{2}$/, phone: /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/, //phone: /^[0-9]*$/, zipUS: /^(\d{5})(-\d{4})?$/, /* /^([0-9]{5})(?:[-\s]([0-9]{4}))?$/; */ zipCanada: /^[a-z][0-9][a-z]\s?[0-9][a-z][0-9]$/i,/* /^([A-Z][0-9][A-Z])\s([0-9][A-Z][0-9])$/; */ zip: /^(?:[A-Z0-9]+([- ]?[A-Z0-9]+))?$/, creditCard: /^\d{13,16}$/, numeric: /^\d+$/, /* [0-9]+ */ number: /^\d+$/, cvvnum: /^\d+$/, /* [0-9]+ */ dollar: /^[$0-9]+/, /* [0-9]+ */ numericNotRequired: /^\d$/, decimal: /^[0-9\.,]+$/, decimalNotRequired: /^[0-9\.,]$/, alphabet: /^[A-Za-z]/, alphabetWithUnderscore: /^[A-Za-z_]/, alphabetWithSpace: /^[A-Za-z ]/, alphanumeric:/^([a-z]|\d|\s|-|\.|_|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+$/i, /*[A-Za-z0-9] */ alphanumericWithUnderscore : /^[A-Za-z0-9_]$/, alphanumericWithSpace: /^[A-Za-z0-9 ]$/, year:/^\d+$/, /* [0-9]+ */ month:/^\d+$/, /* [0-9]+ */ day:/^\d+$/, /* [0-9]+ */ nopobox: /^[^p]{1}[^.]*[^o]{1}[^.]*[^ ]*[^b]{1}[^o]{1}[^x]{1}$/i //physicalAddress: /^[0-9a-zA-Z,. @#$%&*\'`_-]*$\" / } }; var errorsMessage = { en :{ empty: '100', selected:'101', checked: 'Please check', username: 'Valid Usernmae', password: 'Valid Password', email: 'Please enter a valid email address', ip: 'has wrong format. Example: 111.111.111.111', date: 'has wrong format. Example: mm/dd/yyyy', datetime: 'has wrong format. Example: mm/dd/yyyy hh:mm', phone: 'Please enter valid phone number (Ex: 4045551234)', zipUS: 'enter valid USA zipcode.', zipCanada: 'has wrong format. Example: A6A 6A6', zip: 'enter valid USA zipcode.', creditCard: 'credit card number (digits only)', expDateCard: 'enter correct expiration date', cvvnum: 'enter correct 3-digit number', cvv: 'enter correct 3-digit number', numeric: '255', numericNotRequired: 'will allow only numeric', decimal: 'has wrong format', decimalNotRequired: 'has wrong format', cityUS: 'will allow only USA cities', alphabet: 'will allow only alphabet', alphabetWithUnderscore: 'will allow only alphabet with underscore', alphabetWithSpace: 'will allow only alphabet with whitespace', alphanumeric: 'will allow only alphanumeric', alphanumericWithUnderscore : 'will allow only alphanumeric with underscore', alphanumericWithSpace: 'will allow only alphanumeric with whitespace', year:'Please provide valid Year', month:'Please provide valid Month', yearId:'Four-Digit Year', monthId:'Two-Digit Month', dayId:'Two-Digit Day', nopobox: 'No P.O. Boxes Allowed with Fed Ex', correctOrderID:'Please provide a valid Order ID', name: 'Only allow alphabet for names', purchaserFirstname:' Enter valid purchaser first name', purchaserLastname:'Enter valid purchaser last name', physicalAddress:' has wrong Address', purchaserName:'Name on Card is required', homeusername:'Enter valid username', homepassword:'Enter valid password', minlength: '200' }, es:{ empty: 'Por favor introduzca válida', selected:'se debe seleccionar', checked: 'se debe comprobar', email: 'Dirección de correo electrónico no vàlida.', ip: 'tiene un formato incorrecto. Ejemplo: 111.111.111.111', date: 'tiene un formato incorrecto. Ejemplo: mm/dd/yyyy', datetime: 'tiene un formato incorrecto. Ejemplo: mm/dd/yyyy hh:mm', phone: 'Por favor, introduzca el número de teléfono válido Ejemplo: 1234567890', zipUS: 'tiene un formato incorrecto. Ejemplo: 10001', zipCanada: 'tiene un formato incorrecto. Ejemplo: A6A 6A6', zip: 'tiene un formato incorrecto. Ejemplo.', creditCard: 'tiene formato de número equivocado (digits only)', numeric: 'permitirà sólo numérico', number: 'permitirà sólo numérico', numericNotRequired: 'will allow only numeric', decimal: 'tiene formato incorrecto', decimalNotRequired: 'tiene formato incorrecto', alphabet: 'will allow only alphabet', alphabetWithUnderscore: 'will allow only alphabet with underscore', alphabetWithSpace: 'will allow only alphabet with whitespace', alphanumeric: 'will allow only alphanumeric', alphanumericWithUnderscore : 'will allow only alphanumeric with underscore', alphanumericWithSpace: 'will allow only alphanumeric with whitespace', year:'Proporcione Año válida', month:'Proporcione Mes válida', yearId:'Proporcione Año válida', day:'Please provide valid Day', monthId:'Proporcione Mes válida', dayId:'Proporcione Mes vádia', homeusername:'Problemo en llama', homepassword:'Introduzca la contraseña vàlida', minlength: '200' } }; function validateElement(formRef,fieldref){ var totalErrormsg=""; var $fieldref = $(fieldref); var req = $fieldref.attr("mandatory"); var minlength = $fieldref.attr("minlength"); req = (req!=undefined && (req=="required" || req+"" == "true"))?true:false; var validateType = $fieldref.attr("validate"); var errorMsg = ""; var tagType = $fieldref.prop("type").toLowerCase(); var tagName = $.trim($fieldref.prop("tagName")).toLowerCase(); var group= $fieldref.attr("group"); var placeholder = $fieldref.attr('placeholder'); var value = $.trim($fieldref.val()); $fieldref.val(value); var mergeError = $fieldref.attr("mergeError"); var mismatchederror = "Mismatched field"; //alert("errorMsg"+errorMsg); //alert("totalErrormsg"+totalErrormsg.length); var mergeErrorFlag = true; if(!$fieldref.is(":visible")) {return true;} //*new style for error Messages*/ var errorMessageId = $fieldref.attr("errorMessageId"); if(errorMessageId){ $("#"+errorMessageId).empty(); } //*new style for error Messages*/ if(req){ if(tagType=="text" || tagName=="textarea" || tagType=="password"){ if(placeholder!=undefined && $.trim(placeholder)==value){ value = ""; } if(value.length==0){ errorMsg = validatejson.errors.empty; } //*new style for error Messages*/ else if(minlength && !(value.length == minlength)){ errorMsg = (validatejson.errors.minlength).replace("number",minlength); } //*new style for error Messages*/ }else if(tagType=="radio" && !$fieldref.is(":checked")){ var radioFlag = false; if($fieldref.attr("name")!=undefined){ radioFlag = $("input[type=radio][name="+$fieldref.attr("name")+"]").is(":checked"); } if(!radioFlag){ errorMsg = validatejson.errors.checked; } }else if(tagType=="checkbox" && !$fieldref.is(":checked")){ errorMsg = validatejson.errors.checked; } else if((tagName=="select")){ if(mergeError!=undefined){ $("select[mergeError="+mergeError+"]").each(function(index, element) { var innerVal = $.trim($(this).val()); if(innerVal.length==0 || (innerVal+"") == "-1"){ errorMsg = validatejson.errors.selected; alert('you got errors here buddy'); } }); }else if((""+$fieldref.val())=="-1" || $.trim($fieldref.val())==""){ errorMsg = validatejson.errors.selected; } } } if(errorMsg.length==0){ if(tagType=="text" || tagType=="password" || tagName=="textarea"){ var value = $fieldref.val(); if(placeholder!=undefined && $.trim(placeholder)==value){ value = ""; } if(value.length>0){ if(validateType!=undefined && (validatejson.formats[validateType])!=undefined && value.match((validatejson.formats[validateType]))==null){ errorMsg = validatejson.errors[validateType]; }else if(validateType!=undefined && (validateType=="month" ||validateType=="year" || validateType=="date" || validateType=="datetime") && !isValidateDateTime(value,validateType) ){ errorMsg = validatejson.errors[validateType]; }else if($fieldref.attr("maxlength")!=undefined && value.length>$fieldref.attr("maxlength")){ errorMsg ="length should not exceed "+maxlength+" characters"; }else { if(group!=undefined){ $("#"+formRef).find("*[group="+group+"]").each(function(){ if(value!=$.trim($(this).val()) && errorMsg.length==0){ errorMsg = mismatchederror; }else{ var errormsg = $(this).attr("errorMsg"); var prevErrorMsg; if(errormsg!=undefined){ prevErrorMsg= $("#"+$.trim($(this).attr("id"))+"error"); }else{ prevErrorMsg = $(this).parent().find("span.error"); } if((prevErrorMsg!=undefined &&($.trim(prevErrorMsg.text())==$.trim(mismatchederror)))){ prevErrorMsg.hide( "fast").remove(); } } }); } } } } } $("#"+$fieldref.attr("errorMsg")).html(""); $fieldref.parent().find("span.error").hide( "fast").remove(); // alert('turnon dis-able feature'); var flag = true; if(errorMsg.length>0){ //totalErrormsg = ($fieldref.attr("title")==undefined?$fieldref.attr("name"):$fieldref.attr("title"))+" "+errorMsg; totalErrormsg = ($fieldref.attr("title")==undefined?"":$fieldref.attr("title"))+" "+errorMsg; var errormsg = $fieldref.attr("errorMsg"); var errorMsgLocationTag = $fieldref.attr("errorTagClass"); var groupLocation = $fieldref.attr("grouperrorlocation"); //*new style for error Messages*/ if(errorMessageId){ $("#"+errorMessageId).html(totalErrormsg); flag=false; } //*new style for error Messages*/ else if(group && groupLocation==undefined && errorMsg == mismatchederror){ var otherRef = $("[group="+$fieldref.attr("group")+"][grouperrorlocation=true]"); if(otherRef!=undefined && otherRef.val().length > 0){ otherRef.trigger("blur"); } flag=true; }else if(errorMsgLocationTag==undefined){ if(errormsg!=undefined){ $("#"+$.trim($fieldref.attr("id"))+"error").hide( "fast").remove(); var diverrorgen = $("<div/>").css("color","#D00").hide().addClass("error").html(totalErrormsg).attr("id",$.trim($fieldref.attr("id"))+"error"); //var divtext = "<div id='"+$.trim($fieldref.attr("id"))+"error'>"+totalErrormsg+"</div>"; $("."+errormsg).append(diverrorgen).css("color","#D00").hide().show("fast"); alert('turnon dis-able location feature'); }else{ // Bolt Notification Called and Enabled here // if(BoltNotify == true){ // var spanerrorgen = $('.error.message').contents().find('h4').html(totalErrormsg); // VanillaReload.notify.showNotification(".error"); // }else{ // var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(totalErrormsg); // $fieldref.parent().append(spanerrorgen) // spanerrorgen.show("fast"); // } var errorCode = totalErrormsg; _getErrorMessage(errorCode); _stripFields(); $("#button-2").addClass("disabled"); $(".button-2").addClass("disabled"); $("p.links").addClass("disabled"); $(".field.select").addClass("errors"); if(req === false){ $fieldref.removeClass("error"); $fieldref.removeAttr("errorMsg"); $fieldref.removeAttr("class"); }else{ $fieldref.addClass("error"); } $fieldref.removeClass("success"); //$(validatejson.errors.empty).html('Please enter a valid' +$fieldref); //$(validatejson.errors.empty == 'Please enter a valid' +$fieldref); $("input[name*='address2']").removeClass("error"); $("input[name*='emailAddress2']").removeClass("error"); $('input[name^="shippingmethod"]').removeClass("error"); $("select[name*='selectProductAddress']").removeClass("error"); $("input[type='button']").addClass("disabled"); $("button[type='submit']").addClass("disabled"); $("button[type='submit']").attr("disabled", true); $("input[type='button']").attr("disabled", true); $('input[type="submit"]').addClass("disabled"); //$('input[type="Submit"]').attr('disabled','disabled'); $('input[type="submit"]').attr('disabled', true); } }else{ if(errormsg!=undefined){ $("."+errorMsgLocationTag).find("span.error").hide( "fast").remove(); }else{ if($fieldref.attr("customErrorMsg")!=undefined){ totalErrormsg= $fieldref.attr("customErrorMsg"); }else if($fieldref.attr("prefixErrorMsg")!=undefined){ totalErrormsg =$fieldref.attr("prefixErrorMsg")+totalErrormsg; } var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(totalErrormsg); $("."+errorMsgLocationTag).html(spanerrorgen) spanerrorgen.show("fast"); //alert('radio'); } } flag = false; } //*new style for error Messages*/ var otherRef = $("[group="+$fieldref.attr("group")+"]"); if(req === true && flag===true){ $fieldref.removeClass("error"); if(!$fieldref.hasClass("success")){$fieldref.addClass("success");}; if(otherRef){ otherRef.each(function(){ $(this).removeClass("error"); if(!$(this).hasClass("success")){$(this).addClass("success");}; }); } }else if(flag === false){ $fieldref.removeClass("success"); if(!$fieldref.hasClass("error")){$fieldref.addClass("error");}; if(otherRef){ otherRef.each(function(){ $(this).removeClass("success"); if(!$(this).hasClass("error")){$(this).addClass("error");}; }); } }else{ $(this).removeClass("success").removeClass("error"); } //*new style for error Messages*/ return flag; } //*new style for error Messages*/ //var jsonErrors = frontEndErrorCodes; //JC wrote. //MG added. To retrieve Front-end error codes as well as //Backend Error Codes function _getErrorMessage(errorCode, message){ var errorData = JSON.stringify({error_code: errorCode, message: message}); var dataString = $.parseJSON(errorData); $.ajax({ url: './retrieveErrorMessage.json', type: 'POST', data: dataString, dataType: "json", contentType: 'application/json', mimeType: 'application/json', success: function(data) { //data = $.parseJSON(data); // console.log(data); // console.log(errorCode); // console.log(data.error_messages_m); var message = ""; $.each(data.error_messages_m, function(error_code, message ) { if(errorCode == message.error_code && errorCode != -1 ){ console.log(errorCode + message.error_code); console.log(message.message); message = message.message; return false; } //Bolt Notification Called and Enabled here if(BoltNotify == true){ var spanerrorgen = $('.error.message').contents().find('h4').html(message); VanillaReload.notify.showNotification(".error"); }else if(BoltNotify == true && multipleNotice ==true ){ var spanerrorgen = $('.error.message').contents().find('h4').html(message); VanillaReload.notify.showNotification(".error").append(spanerrorgen); }else{ var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(message); $fieldref.parent().append(spanerrorgen) spanerrorgen.show("fast"); } }); }, error: function(data) { //data = $.parseJSON(data); console.log(data); console.log(errorCode); console.log(data.message); //Bolt Notification Called and Enabled here if(BoltNotify == true){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.error_messages_m); VanillaReload.notify.showNotification(".error"); }else if(BoltNotify == true && multipleNotice == true ){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error").append(spanerrorgen); }else{ var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(data.message); $fieldref.parent().append(spanerrorgen) spanerrorgen.show("fast"); } }, fail: function(jqXHR, textStatus) { alert(data); if(textStatus == "parsererror"){ return "We're Sorry a system error occured"; } } }); } function isValidateDateTime(value,type){ value = $.trim(value); if(type=="year"){ var year = (new Date().getFullYear()-parseInt(value,10)); //alert(year); return (year>=18 && year<=150); } if(type=="month"){ var month = parseInt(value,10); //alert(month); return (month>=1 && month<=12); } var maxlength = 10; //date if(type==validatejson.formats.date && value.length == 10){ return isValidateDate(value); }else if(type==validatejson.formats.datetime && value.length == 19){ var datetimestr = value.split(" "); if(datetimestr.length == 2){ return (isValidateTime(datetimestr[1])&&isValidateDate(datetimestr[0])); } } return false; } function isValidateTime(value){ var timearr = value.split(":"); if(!(timearr.length==3 && timearr[0]<24 && timearr[0]>-1 && timearr[1]<60 && timearr[1]>-1&& timearr[2]<60 && timearr[2]>-1)){ return false; } return true; } function isValidateDate(value){ if(value == '') return false; var rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/; //Declare Regex var dtArray = value.match(rxDatePattern); // is format OK? if (dtArray == null) return false; //Checks for mm/dd/yyyy format. dtMonth = dtArray[1]; dtDay= dtArray[3]; dtYear = dtArray[5]; if (dtMonth < 1 || dtMonth > 12) return false; else if (dtDay < 1 || dtDay> 31) return false; else if ((dtMonth==4 || dtMonth==6 || dtMonth==9 || dtMonth==11) && dtDay ==31) return false; else if (dtMonth == 2){ var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0)); if (dtDay> 29 || (dtDay ==29 && !isleap)) return false; } return true; } function languageMessage(lang){ validatejson.errors=((errorsMessage[lang]!=undefined)?errorsMessage[lang]:errorsMessage['en']); } function bindValidation(formRef,lang){ //alert("#"+formRef); languageMessage(lang); $("#"+formRef).find("input:text,input:password,input:radio,input:checkbox,select,textarea").focus(function(){ $(this).parent().find("span.error").hide( "fast").remove(); $(this).parent().find(".field.select.errors").hide( "fast").remove(); $("#"+$.trim($(this).attr("id"))+"error").hide( "fast").remove(); $(".buttonTwo").removeClass("disabled"); $("#button-2").removeClass("disabled"); $(".button-2").removeClass("disabled"); $(".field.select").removeClass("errors"); //$(".ssntip2").removeClass("errors"); //$(".securityCodetip2").removeClass("errors"); //$("form#account_signin_form .button.alternate.username.password").css("top", "10px"); $('input[type="submit"]').removeAttr('disabled'); $('input[type="submit"]').removeClass("disabled"); $("button[type='submit']").removeClass("disabled"); $("button[type='submit']").removeAttr("disabled", true); }); $("#"+formRef).find("input:text,input:password,input:radio,input:checkbox,select,textarea").blur(function(){ //alert("sai"); validateElement(formRef,this); }); $("select[name='alternateIdType']").change(function(e){ String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g, '');} $("input[name='identificationNumber']").parent().find("span.error").remove(); $("input[name='alternateIdNumber'],select[name='selectBoxExpMonth'],select[name='selectBoxExpDay'],select[name='selectBoxExpYear']").parent().find("span.error").remove(); var mandatory = true; if(($(this).val().trim()+'')=== '-1'){ $("input[name='identificationNumber']").attr("validate","number").attr("mandatory",mandatory); $("input[name='alternateIdNumber'],select[name='selectBoxExpMonth'],select[name='selectBoxExpDay'],select[name='selectBoxExpYear']").removeAttr("validate","number").removeAttr("mandatory",true); }else{ mandatory = false; $("input[name='identificationNumber']").removeAttr("validate","number").removeAttr("mandatory",mandatory); $("input[name='alternateIdNumber'],select[name='selectBoxExpMonth'],select[name='selectBoxExpDay'],select[name='selectBoxExpYear']").attr("validate","alphanumeric").attr("mandatory",true); } //*new style for error Messages*/ if($(this).hasClass("parent")){ $("[dependency="+$(this).attr("dependency")+"].child").each(function(e){ var dependencymandatory = $(this).attr("mandatory"); if( dependencymandatory === true){ if(this.value){ $(this).removeClass("error"); if(!$(this).hasClass("success")){$(this).addClass("success");}; }else{ $(this).removeClass("success"); if(!$(this).hasClass("error")){$(this).addClass("error");}; } }else{ $(this).removeClass("success").removeClass("error"); } }); } });//*new style for error Messages*/ $("select[name='alternateIdType']").trigger("change"); _stripFields(); } //Submit. Disable and call to modalpoplite for loading the wait page //MG added these features in here so that Jquery Can be used on any site built from here moving forward //Can be modified id known more about jQuery, feel free to update as see fit, if you*r b:tt3r d4n |'|3 //Sai S.. Added the validation. Great Job Sai!!!! :-) function isValidation(formRef,lang){ //alert("#"+formRef); languageMessage(lang); var status = true; $("#"+formRef).find("input:text,input:password,input:radio,input:checkbox,select,textarea").each(function(){ var innerstatus = validateElement(formRef,this); _stripFields(); if(!innerstatus){ status=false //alert('form submitting here'); $("input[name*='address2']").removeClass("error"); $("input[name*='emailAddress2']").removeClass("error"); $("button[type='submit']").addClass("disabled"); $("button[type='submit']").attr("disabled", true); $("#UserLogin").addClass("disabled"); $("#profileSubmitButton_en").addClass("disabled"); $("#profileSubmitButton").addClass("disabled"); $('input[type="submit"]').addClass("disabled"); $('input[type="submit"]').attr("disabled", true); $("input[type='button']").addClass("disabled"); $("button[type='submit']").addClass("disabled"); }else{ //alert('this form is submitting now'); $("input[name*='address2']").removeClass("error"); $("input[name*='emailAddress2']").removeClass("error"); $("select[name*='selectProductAddress']").removeClass("error"); $("button[type='submit']").attr("disabled", true); $("button[type='submit']").addClass("disabled"); $('input[type="submit"]').addClass("disabled"); //$('#loading-div-background').modalPopLite({ openButton: '#clicker', closeButton: '#close-btn', isModal: true }); } }); return status; //var flag=false; //formResult= $("#"+formRef).find.each(function(){ flag=true; alert(flag);});("span.error")==undefined?true:false; //alert("formResult....."+formResult); //return formResult; ////alert("message..."+$("#"+formRef).find("span.error").attr("class")); // return $("#"+formRef).find("span.error").attr("class")==undefined?true:false; } function isHomeValidation(formRef,lang){ //alert("#"+formRef); languageMessage(lang); var status = true; $("#"+formRef).find("input:text,input:password,input:radio,input:checkbox,select,textarea").each(function(){ var innerstatus = validateElement(formRef,this); //alert("inner" + innerstatus); //alert("status" + status); status = status && innerstatus; }); if(!status){ $(".homeLogin").addClass("disabled"); //$("p.links").hide(); }else{ $(".homeLogin").addClass("disabled"); // $("#UserLogin").removeClass("disabled"); // $("#UserLogin").removeAttr("disabled"); //$('input[type="submit"]').attr('disabled','disabled'); $("#loading-div-home").css({ opacity: 1.0 }); $('#loading-div-home').show(); $('#loading-div-home').css('display', 'block'); } return status; } //MG added this for car customization //01-2014 //This is a seperate validation form function isPayValidation(formRef,lang){ //alert("#"+formRef); languageMessage(lang); var status = true; $("#"+formRef).find("input:text,input:password,input:radio,input:checkbox,select,textarea").each(function(){ var innerstatus = validateElement(formRef,this); _stripFields(); if(!innerstatus){ status=false //alert('form submitting here'); //$("#place_order").attr("disabled", true); $('#application_submit_order').addClass('hasErrors'); $('#application_submit_order').removeClass('noErrors'); $("input[name*='address2']").removeClass("error"); $('input[type="submit"]').addClass("disabled"); $('input[type="submit"]').attr('disabled','disabled'); }else{ $('#application_submit_order').removeClass('hasErrors'); $('#application_submit_order').addClass('noErrors'); $("#place_order").addClass("disabled"); //return false; } }); return status; $("input[name*='address2']").removeClass("error"); } //MG.added 07/2014. J.C. Coded this //Strips non numeric characters from the given input field. function _stripFields() { stripChars('pinNumber', /\D/g); stripChars('txtCardNum', /\D/g); stripChars('amt', /\D/g); stripChars('txtZip', /\D/g); stripChars('txtPhone', /\D/g); stripChars('phone', /\D/g); stripChars('cardNum', /\D/g); stripChars('siccode', /\D/g); stripChars('postalcode', /\D/g); } /** * Strips non numeric characters from the given input field. * @param {[type]} input the input field to be stripped. * @param {[regex]} regex string of allowed characters /\W/g for alphanumeric /\D/g for digits * @return {[type]} none */ function stripChars(input, regex){ var originalMaxLength = $('#' + input).attr('maxlength'); $('#' + input).on('keyup', function (event) { if(!(event.keyCode <= 46)) { var val = $( this ).val(); $( this ).val(charStripper(val, originalMaxLength, regex)); $( this ).attr('maxlength', originalMaxLength); } }); $('#' + input).on('paste', function() { $(this).attr('maxlength', 100); element = $(this); setTimeout(function() { var val = element.val(); element.val(charStripper(val, originalMaxLength, regex)); element.attr('maxlength', originalMaxLength); }, 100); }); } /** * Removes all non numeric characters from a string and shortens the string to the max length of the input field being used. * @param {[type]} str The string to be stripped. * @param {[type]} maxlength The max length of the input field being used. * @param {[boolean]} allowLetters If true it strips only special characters. If False it strips all non numeric characters. * @return {[type]} The stripped string. */ function charStripper(str, maxLength, regex) { str = str.replace(regex,''); str = str.substring(0, maxLength); return str; } //Application From Validation Processing //Mg. 07.2014 //Personlize & Customize Validation placed here if($('.manageYourCard').length > 0) { _applyNow(); } function _applyNow(){ // $('*[mandatory="true"]').attr('mandatory', 'false'); // REMOVE Deactivates Front End Validations bindValidation("vrn_form","${pageContext.response.locale}"); $("#btn_load_fund").click(function(){ var result = isValidation("vrn_form","${pageContext.response.locale}"); //alert("Result is now... : [" + result + "]"); if (result == true) { //alert("Let us invoke the JSON call now..."); return false; } else { return false; } }); } //Application From Validation Processing //Mg. 07.2014 //Refund Request Forms //All Three Forms if($('.refundRequest').length > 0) { _refundRequests(); } function _refundRequests(){ // $('*[mandatory="true"]').attr('mandatory', 'false'); // REMOVE Deactivates Front End Validations bindValidation("refundForm","${pageContext.response.locale}"); $("#refundRequestBtn").click(function(){ var result = isPayValidation("refundForm","${pageContext.response.locale}"); if (result == true) { //alert("Let us invoke the JSON call now..."); return false; } else { return false; } }); } //Application From Validation Processing //Mg. 07.2014 //Store Locator Validation if($('.homepageInfo').length > 0) { _locatorNow(); } function _locatorNow(){ // $('*[mandatory="true"]').attr('mandatory', 'false'); // REMOVE Deactivates Front End Validations bindValidation("locator","${pageContext.response.locale}"); $("#btnZip").click(function(){ var result = isValidation("locator","${pageContext.response.locale}"); //alert("Result is now... : [" + result + "]"); if (result == true) { //alert("Let us invoke the JSON call now..."); return false; } else { return false; } }); } //Application From Validation Processing //Mg. 07.2014 //Get Scoop Email Validation if($('.getTheScoop').length > 0) { _getTheScoop(); } function _getTheScoop(){ // $('*[mandatory="true"]').attr('mandatory', 'false'); // REMOVE Deactivates Front End Validations bindValidation("newsletter","${pageContext.response.locale}"); $("#btnGo").click(function(){ var result = isValidation("newsletter","${pageContext.response.locale}"); //alert("Result is now... : [" + result + "]"); if (result == true) { //alert("Let us invoke the JSON call now..."); return false; } else { return false; } }); }
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.