Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. <script language=javascript>
  2. function validateForm() {
  3.  
  4. var divs = $('.npt');
  5.  
  6. var ctrl_vacios=true;
  7.  
  8. if (valida_longitud() == false) {
  9. if (document.getElementById("ErrorValidacio") != null) {
  10. eliminarNode(document.getElementById("ErrorValidacio"));
  11. }
  12. var texteError = " (*) S'ha d'informar minim de 3-4 caracters";
  13. var btn = document.createElement("p");
  14. btn.setAttribute("id","ErrorValidacio");
  15. btn.style.color= "red";
  16. if (document.getElementById("ErrorValidacio") == '' || document.getElementById("ErrorValidacio") == null ){
  17. var t = document.createTextNode(texteError);
  18. btn.appendChild(t);
  19. var elem = document.getElementById('cercar_cataleg_producte');
  20. elem.appendChild(btn);
  21. return false;
  22. }
  23. else{ return false; }
  24. }
  25. for(var i=0;i<divs.length; i++){
  26. var elem = divs[i];
  27. if (elem.value.replace(/^\s+|\s+$/g,'') != '')
  28. {
  29. ctrl_vacios=false;
  30. }
  31. }
  32. if(ctrl_vacios){
  33. if (document.getElementById("ErrorValidacio") != null) {
  34. eliminarNode(document.getElementById("ErrorValidacio"));
  35. }
  36. var texteError = " (*) S'ha d'informar almenys un camp del formulari";
  37. var btn = document.createElement("p");
  38. btn.setAttribute("id","ErrorValidacio");
  39. btn.style.color= "red";
  40. if (document.getElementById("ErrorValidacio") == '' || document.getElementById("ErrorValidacio") == null ){
  41. var t = document.createTextNode(texteError);
  42. btn.appendChild(t);
  43. var elem = document.getElementById('cercar_cataleg_producte');
  44. elem.appendChild(btn);
  45. return false;
  46. }
  47. else{ return false; }
  48. }
  49. }
  50.  
  51. function valida_longitud() {
  52.  
  53. var divs = $('.npt');
  54.  
  55. for(var i=0;i<divs.length; i++){
  56. divs[i].removeAttribute("style");
  57. }
  58.  
  59. var divs = $('.inputCodi');
  60. for(var i=0;i<divs.length; i++) {
  61. var elem = divs[i];
  62. elem = elem.value.replace(/^\s+|\s+$/g,'');
  63. if (elem.length < 3) {
  64. if (elem.length != 0) {
  65. divs[i].style.backgroundColor= '#ffcccc';
  66. divs[i].style.borderColor= "red";
  67. return false;
  68. }
  69. }
  70. else { return true; }
  71. }
  72. var divs = $('.inputDesc');
  73. for(var i=0;i<divs.length; i++) {
  74. var elem = divs[i];
  75. elem = elem.value.replace(/^\s+|\s+$/g,'');
  76. if (elem.length < 4 ) {
  77. if (elem.length != 0) {
  78. divs[i].style.backgroundColor= '#ffcccc';
  79. divs[i].style.borderColor= "red";
  80. return false;
  81. }
  82. }
  83. else { return true; }
  84. }
  85. }
  86.  
  87. function eliminarNode(node) {
  88. node.parentNode.removeChild(node);
  89. }
  90. </script>
  91.  
  92. <style>
  93.  
  94. .npt {
  95. text-align: left;
  96. padding: 6px 19px;
  97. font-size: .875em;
  98. border-radius: 4px;
  99. cursor: text;
  100. border: 1px solid #ccc !important;
  101. }
  102.  
  103. @media (min-width: 1200px) {
  104. .escalableNut {
  105. margin-top:30px;
  106. }
  107. }
  108.  
  109. @media (max-width: 1199px) and (min-width: 992px) {
  110. .escalableNut {
  111. margin-top:8px;
  112. }
  113. }
  114.  
  115. @media (max-width: 991px) and (min-width: 768px) {
  116. .escalableNut {
  117. margin-top:52px;
  118. }
  119. }
  120.  
  121. @media (max-width: 767px) {
  122. .escalableNut {
  123. margin-top:30px;
  124. }
  125. /*afegir en sm i xs margins als cuadres i al botó!!*/
  126. }
  127. </style>
  128.  
  129. <h3>Catàleg de productes farmacèutics. Productes dietoterapèutics</h3>
  130. <p>Ompliu els camps que vulgueu i feu clic a “Cercar”. Com més camps empleneu més exacte serà el resultat de la vostra petició.</p>
  131. <form id="cercar_cataleg_producte" method="get" accept-charset="iso-8859-1" action="./resultats/">
  132. <input type="hidden" name="P_PAGINACIO" value="S"/>
  133. <input type="hidden" name="P_ELEMENT_INICIAL" value="0"/>
  134. <input type="hidden" name="P_MAX_PAGINES" value="15"/>
  135. <input type="hidden" name="P_NUM_ELEMENTS" value="40"/>
  136. <input type="hidden" name="P_CERCA" value="G"/>
  137. <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
  138. <br>
  139. <h5><strong>Producte</strong></h5>
  140. Poseu el codi o part del nom per triar per producte.<br/>
  141. (especialitat farmacèutica, efectes i accessoris, o nutrients).
  142. <br>
  143. <div style="margin-top:30px">
  144. <label>Codi</label>
  145. <br>
  146. <input type="text" name="P_CPRODUCTE" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 npt" maxlength="8" value="">
  147. </div>
  148. <div style="margin-top:30px">
  149. <label>Descripció</label>
  150. <br>
  151. <input type="text" name="P_DPRODUCTE" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 npt" maxlength="30" value="">
  152. </div>
  153. </div>
  154. <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
  155. <br>
  156. <h5><strong>Subgrup de nutrient</strong></h5>
  157. Poseu el codi o part del nom per triar per subgrup de nutrient.<br/><br/>
  158. <div class="escalableNut">
  159. <label>Codi</label>
  160. <br>
  161. <input type="text" name="P_CNUTRIENT" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 npt" maxlength="8" value="">
  162. </div>
  163. <div style="margin-top:30px"">
  164. <label>Descripció</label>
  165. <br/>
  166. <input type="text" name="P_DNUTRIENT" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 npt" maxlength="30" value="">
  167. <input class="btn bgRed white boto-modal-enviar pull-right" onclick="return validateForm();" value="Cerca" type="submit" style="width:90px;margin-top:15px;margin-left:15px;border:0px !important">
  168. </div>
  169. </div>
  170.  
  171. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement