http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

Public

Warning message

We recommend you to assign at least one category to this snippet so you could easily navigate it in the future. Edit your snippet here.

Zencart code of JS

Get raw version
javascript
  1. /**
  2.  * @package pearltea
  3.  * @copyright Copyright 2007 LightInTheBox Team
  4.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  5.  * @version $Id: frmCheck.js - create by tankai 2007-10-19
  6.  */
  7.  
  8. function field_check(name, rule, field){
  9. if(rule.indexOf("cpwd")>-1){
  10. strTmp = rule.split("#");
  11. if(strTmp[0].inc("cpwd","/") == true && field.value != $(strTmp[1]).value){
  12. return "The "+name+" must match your " +name.split(" Confirmation")[0];
  13. }
  14. }
  15. if(rule.inc("eml","/")==true && !/(\,|^)([\w+._]+@\w+\.(\w+\.){0,3}\w{2,4})/.test(field.value.replace(/-|\//g,"")) && !isNone(field.value)){
  16. return "Is your " + name + " correct? Sorry, my system does not understand your email address.";
  17. }
  18. if(rule.inc("tel","/")==true && !/(^[0-9+-]{3,30}$)/.test(field.value) && !isNone(field.value)){
  19. return "Is your "+name+" correct? Sorry, my system does not understand your telephone format.";
  20. }
  21. size = rule.sub("min","/");
  22. if(size > 0 ){
  23. if(field.value.trim().length < size && field.value.trim().length>0){
  24. return "Is your "+ name +" correct? Our system requires a minimum of "+size+" characters.";
  25. }
  26. }
  27. size = rule.sub("max","/");
  28. if(size > 0 ){
  29. if(field.value.trim().length > size){
  30. return "Is your "+ name +" correct? Our system requires a maximum of "+size+" characters."
  31. }
  32. }
  33. if(rule.inc("nnull","/") == true && isNone(field.value)){
  34. return "Sorry, "+name+" information is required.";
  35. }
  36. if(rule.inc("ischeck","/") == true && ! field.checked ){
  37. return name;
  38. }
  39. if(rule.inc("isselect","/") == true && field.value == '-1' ){
  40. return 'Please Choose "' + name + '"';
  41. }
  42. return "";
  43. };
  44.  
  45. /*#琛ㄥ崟楠岃瘉#*/
  46. function fmChk(fm){
  47. var name , rule , tmp , msgStr , size;
  48. if(fm == null || fm.tagName != "FORM"){
  49. alert("", null , "error");
  50. return;
  51. }
  52. for(i=0;i<fm.length;i++){
  53. var msgStr = chkInput(fm[i]);
  54. if(msgStr != "success"){
  55. efocu(fm[i]);
  56. msg(msgStr);
  57. return false;
  58. }
  59. }
  60. return true;
  61. };
  62.  
  63. function chkInput(obj){
  64. var name , rule , msgStr;
  65. name=obj.getAttribute("chkName");
  66. rule=obj.getAttribute("chkRule");
  67. if(isNone(rule) || isNone(name)) return "success";
  68. msgStr = field_check(name, rule, obj);
  69.  
  70. if(msgStr != ""){
  71. return msgStr;
  72. }
  73. else{
  74. return "success";
  75. }
  76. };
  77.  
  78. function msg(key){
  79. alert(key);
  80. };
  81.  
  82. function initForm(el, func){
  83. var img_path = baseURL + "includes/templates/lightinthebox/images/checkout";
  84. (new Image(10,10)).src = img_path + "/ico_F.gif";
  85. var error_bg = "#FEDFDF", blur_bg = "" , focus_bg = "#FFFEE1";
  86. var formId = $(el);
  87. if(formId == null || formId.tagName != "FORM"){
  88. alert("", null , "error");
  89. return;
  90. }
  91. var addImage = '<img src="'+ img_path + "/ico_T.gif" +'" width="10" height="10" style="display:none;" class="pad_l"/>';
  92. var addDiv = '<div style="display:none;" class="red line_120"></div>';
  93. var elArr = formId.elements;
  94. var elLen = elArr.length;
  95. for(i=0; i<elLen; i++) {
  96. //insert the img and div
  97. var addHtml = elArr[i].getAttribute("chkRule");
  98. if(addHtml){
  99. insHtm(elArr[i],addImage);
  100. insHtm(elArr[i],addDiv);
  101.  
  102. //add the mouse style have check;
  103. elArr[i].onfocus = function(){
  104. if((this.tagName === "INPUT" && (this.type === "text" || this.type === "password"))||this.tagName === "TEXTAREA")
  105. {this.style.backgroundColor = focus_bg;}
  106. }
  107. elArr[i].onblur = function(){
  108. this.style.backgroundColor = blur_bg;
  109. var out_img = this.parentNode.getElementsByTagName("img")[0];
  110. var out_text = this.parentNode.getElementsByTagName("div")[0];
  111. var msg = chkInput(this);
  112. if(msg === "success") {
  113. out_img.src = img_path + "/ico_T.gif";
  114. out_img.style.display="inline";
  115. out_text.style.display="none";
  116. }else{
  117. out_img.src = img_path + "/ico_F.gif";
  118. out_img.style.display="inline";
  119. out_text.innerHTML = msg;
  120. out_text.style.display="block";
  121. if((this.tagName === "INPUT" && (this.type === "text" || this.type === "password"))||this.tagName === "TEXTAREA"){
  122. this.style.backgroundColor = error_bg;
  123. }
  124. }
  125. if(func != null) {try{eval(func);}catch(e){}}
  126. }
  127. }else{
  128. //add the mouse style not check;
  129. if((elArr[i].tagName === "INPUT" && (elArr[i].type === "text" || elArr[i].type === "password"))||elArr[i].tagName === "TEXTAREA"){
  130. elArr[i].onfocus = function(){this.style.backgroundColor = focus_bg;}
  131. elArr[i].onblur = function(){this.style.backgroundColor = blur_bg; if(func != null) {try{eval(func);}catch(e){}}}
  132. }
  133. }
  134. }
  135. }
  136.  
  137.  
  138. p><a href="http://www.ztwshop.com">ZTW Brushless ESC</a></p>
  139. <p> <a href="http://www.ztwshop.com">Brushless ESC </a></p>
  140. <p><a href="http://www.ztwshop.com">ZTW </a></p>
  141. <p><a href="http://www.dreamboxstore.com">Dreambox dm900 hd 4k</a></p>
  142. <p> <a href="http://www.dreamboxstore.com">DM900 hd 4K</a></p>
  143. <p><a href="http://www.dreamboxstore.com">Ultra HD 900 hd 4K </a></p>
  144. <a href="http://www.keruistore.com">kerui alarm </a>
  145. <a href="http://www.sunraysat.com/vu-plus-solo-4k-twin-2x-dvb-s2-linux-satellite-receiver.php" alt="Vu Solo 4K with Twin Tuners">Vu Solo 4K </a>
  146.  
  147. <a href="http://www.xtrons-store.com">Headrest DVD player </a>
  148. <a href="http://www.keruistore.com">kerui alarm Store </a>
  149. <a href="http://www.projector-store.com">DLP HD projector </a>
  150. <a href="http://www.hikvisionstores.com">Hikvision Store </a>
  151. <a href="http://www.naviskautostore.com">Naviskauto Headrest DVD</a>
  152. <a href="http://www.hikvisionstores.com">Hikvision Ip camera </a>
  153. <a href="http://www.sunraybox.com">SunrayBox </a>

Comments