templates/Partial/demande_form.html.twig line 1

Open in your IDE?
  1. {% form_theme demande_form 'Form/exacompare.html.twig' %}
  2. {{ form_start(demande_form, {'attr': {'class': 'request-form form', 'enctype': "multipart/form-data"}}) }}
  3. <div class="inner-form col-sm-12">
  4. <div class="table-form request-form-field cat row">
  5. <div id="categorie" class="col-sm-12">
  6. {{ form_label(demande_form.categorie) }}
  7. <div class="form-fields clearfix">
  8. {{ form_widget(demande_form.categorie) }}
  9. {{ form_errors(demande_form.categorie) }}
  10. </div>
  11. </div>
  12. </div>
  13. <fieldset>
  14. <legend>Votre bien</legend>
  15. <div class="table-form row">
  16. <div class="col-sm-12">
  17. {{ form_label(demande_form.bienType) }}
  18. <div class="form-fields clearfix">
  19. {{ form_widget(demande_form.bienType) }}
  20. {{ form_errors(demande_form.bienType) }}
  21. </div>
  22. </div>
  23. </div>
  24. <div class="table-form row">
  25. <div class="col-sm-12">
  26. {{ form_label(demande_form.bienLocalisation) }}
  27. <div class="form-fields clearfix localisation-container">
  28. {{ form_widget(demande_form.bienLocalisation) }}
  29. {{ form_errors(demande_form.bienLocalisation) }}
  30. </div>
  31. </div>
  32. {{ form_row(demande_form.bienCodePostal, {'row_attr': {'class': 'col-sm-6'}}) }}
  33. {{ form_row(demande_form.bienVille, {'row_attr': {'class': 'col-sm-6'}}) }}
  34. </div>
  35. <div class="table-form row">
  36. <div class="col-sm-4">
  37. {{ form_label(demande_form.bienNombrePieces) }}
  38. <div class="form-fields clearfix">
  39. {{ form_widget(demande_form.bienNombrePieces) }}
  40. {{ form_errors(demande_form.bienNombrePieces) }}
  41. </div>
  42. </div>
  43. <div class="col-sm-4">
  44. {{ form_label(demande_form.bienSurface) }}
  45. <div class="form-fields clearfix">
  46. {{ form_widget(demande_form.bienSurface) }}
  47. {{ form_errors(demande_form.bienSurface) }}
  48. </div>
  49. </div>
  50. <div class="col-sm-4" data-groups="diagnostics">
  51. {{ form_label(demande_form.bienAnneeConstructionChoice) }}
  52. <div class="form-fields clearfix">
  53. {{ form_widget(demande_form.bienAnneeConstructionChoice) }}
  54. {{ form_errors(demande_form.bienAnneeConstructionChoice) }}
  55. </div>
  56. </div>
  57. <div class="col-sm-4" data-groups="expertises etudes solutions energies">
  58. {{ form_label(demande_form.bienAnneeConstructionFree) }}
  59. <div class="form-fields clearfix">
  60. {{ form_widget(demande_form.bienAnneeConstructionFree) }}
  61. </div>
  62. {{ form_errors(demande_form.bienAnneeConstructionFree) }}
  63. </div>
  64. </div>
  65. <div class="table-form row">
  66. <div class="col-sm-4">
  67. {{ form_label(demande_form.bienCopropriete) }}
  68. <div class="form-fields clearfix">
  69. {{ form_widget(demande_form.bienCopropriete) }}
  70. {{ form_errors(demande_form.bienCopropriete) }}
  71. </div>
  72. </div>
  73. <div class="col-sm-4" data-groups="diagnostics">
  74. {{ form_label(demande_form.bienGaz) }}
  75. <div class="form-fields clearfix">
  76. {{ form_widget(demande_form.bienGaz) }}
  77. {{ form_errors(demande_form.bienGaz) }}
  78. </div>
  79. </div>
  80. <div class="col-sm-4" data-groups="diagnostics">
  81. {{ form_label(demande_form.bienElectricite) }}
  82. <div class="form-fields clearfix">
  83. {{ form_widget(demande_form.bienElectricite) }}
  84. {{ form_errors(demande_form.bienElectricite) }}
  85. </div>
  86. </div>
  87. {# <div class="col-sm-8">
  88. <div class="form-label">
  89. <label for="demande_bienPhoto">Joignez une photo (10&nbsp;Mo max)</label>
  90. </div>
  91. <div class="form-fields clearfix">
  92. <span class="browse-button row">
  93. <span class="col-md-6">
  94. <input class="hide" type="file" id="demande_bienPhoto" name="bienPhoto">
  95. <button class="browse" type="button">Parcourir</button>
  96. </span>
  97. <span class="file col-md-6">Aucun fichier sélectionné.</span>
  98. </span>
  99. </div>
  100. </div> #}
  101. </div>
  102. </fieldset>
  103. <fieldset>
  104. <legend>Votre projet</legend>
  105. <div class="table-form row">
  106. <div class="col-sm-4" data-groups="solutions energies">
  107. <div class="form-label">
  108. {{ form_label(demande_form.prestation) }}
  109. </div>
  110. <div class="form-fields clearfix">
  111. {{ form_widget(demande_form.prestation) }}
  112. </div>
  113. {{ form_errors(demande_form.prestation) }}
  114. </div>
  115. {# <div class="col-sm-4">
  116. <div class="form-label">
  117. {{ form_label(demande_form.expiration) }}
  118. </div>
  119. <div class="form-fields clearfix">
  120. {{ form_widget(demande_form.expiration) }}
  121. {{ form_errors(demande_form.expiration) }}
  122. </div>
  123. </div> #}
  124. {# <div class="browse-button col-sm-8" data-groups="expertises etudes solutions energies" style="">
  125. <div class="form-label">
  126. <div class="form-label">
  127. <label for="demande_descriptionFile">Joignez un descriptif (10&nbsp;Mo max)</label>
  128. </div>
  129. </div>
  130. <div class="form-fields clearfix">
  131. <span class="browse-button row">
  132. <span class="col-md-6">
  133. <input class="hide" type="file" id="demande_descriptionFile" name="descriptionFile">
  134. <button class="browse" type="button">Parcourir</button>
  135. </span>
  136. <span class="file col-md-6">Aucun fichier sélectionné.</span>
  137. </span>
  138. </div>
  139. </div> #}
  140. <div class="col-sm-12">
  141. <div class="form-label">
  142. {{ form_label(demande_form.comment) }}
  143. </div>
  144. <div class="form-fields clearfix">
  145. {{ form_widget(demande_form.comment) }}
  146. </div>
  147. {{ form_errors(demande_form.comment) }}
  148. </div>
  149. </div>
  150. </fieldset>
  151. <fieldset>
  152. <legend>Vous-même</legend>
  153. <div class="table-form row">
  154. {% block warning_privacy %}
  155. <p class="form-message col-sm-12">
  156. Vos données personnelles (nom, email, téléphone) ne seront pas utilisées à des fins publicitaires.
  157. </p>
  158. <p class="form-message col-sm-12">
  159. Attention, si vos informations ci-dessous sont inexactes, votre demande ne sera pas traitée.
  160. </p>
  161. {% endblock %}
  162. <div class="col-sm-4 hidden">
  163. {{ form_label(demande_form.clientStatut) }}
  164. <div class="form-fields clearfix">
  165. {{ form_widget(demande_form.clientStatut) }}
  166. {{ form_errors(demande_form.clientStatut) }}
  167. </div>
  168. </div>
  169. <div class="col-sm-4">
  170. {{ form_label(demande_form.clientNom) }}
  171. <div class="form-fields clearfix">
  172. {{ form_widget(demande_form.clientNom) }}
  173. {{ form_errors(demande_form.clientNom) }}
  174. </div>
  175. </div>
  176. <div class="col-sm-4">
  177. {{ form_label(demande_form.clientEmail) }}
  178. <div class="form-fields clearfix">
  179. {{ form_widget(demande_form.clientEmail) }}
  180. {{ form_errors(demande_form.clientEmail) }}
  181. </div>
  182. </div>
  183. <div class="col-sm-4">
  184. {{ form_label(demande_form.clientTelephone) }}
  185. <div class="form-fields clearfix">
  186. {{ form_widget(demande_form.clientTelephone) }}
  187. {{ form_errors(demande_form.clientTelephone) }}
  188. </div>
  189. </div>
  190. </div>
  191. </fieldset>
  192. <div class="row">
  193. {# <div class="estimation declaration">
  194. <div class="form-fields col-sm-12">
  195. <input type="checkbox" id="estimation" name="estimation" {% if demande is defined and demande.estimation %}value="on" checked{% endif %}>
  196. <label id="label_estimation" class=""><p>De plus, je souhaite faire estimer gratuitement mon bien par un agent immobilier</p></label>
  197. </div>
  198. </div> #}
  199. {% block warning %}
  200. <p class="form-message col-sm-12">
  201. En validant ce formulaire, j'accepte que jusqu'à 3 prestataires me contactent pour me fournir un devis gratuit.
  202. </p>
  203. {% endblock %}
  204. <p class="form-required-legend form-message col-sm-12">
  205. <span class="required form-required-mark">*</span> Champ obligatoire.
  206. </p>
  207. </div>
  208. <div class="request-form-submit clearfix row">
  209. {{ form_row(demande_form.submit, {'type': 'button', 'attr': {'onclick': 'requiredVerification()'}}) }}
  210. </div>
  211. </div>
  212. {{ form_end(demande_form) }}
  213. <script>
  214. {# $('#demande_clientTelephone').on('keyup', function () {
  215. var phone = $(this).val();
  216. $('#demande_clientTelephone').val(phone.replace(/[^0-9]/g, ''));
  217. }); #}
  218. $('select#demande_categorie').removeAttr('required')
  219. var form_demande_validated = false;
  220. $("form").submit(function(e){
  221. if (!form_demande_validated) {
  222. e.preventDefault(e);
  223. requiredVerification();
  224. }
  225. });
  226. function requiredVerification() {
  227. form_demande_validated = true;
  228. $("form ul.form-errors").remove();
  229. $('#categorie select:visible, #demande_bienType').each(function () {
  230. if (!$(this).val() || $(this).val() == '') {
  231. $(this).parent(".select-background").after("<ul class='form-errors'><li>Veuillez renseigner ce champ.</li></ul>");
  232. if (form_demande_validated) {
  233. this.setCustomValidity("Veuillez renseigner ce champ.");
  234. $(this).focus();
  235. $('html, body').animate({ scrollTop: $(this).parent(".select-background").offset().top - 110}, 50);
  236. }
  237. form_demande_validated = false;
  238. } else {
  239. this.setCustomValidity("");
  240. }
  241. })
  242. if (!$('.auto_cp').val() || $('.auto_cp').val() == '' || !$('.auto_ville').val() || $('.auto_ville').val() == '') {
  243. if ($(".localisation").val() == '' || !$('.localisation').val()) {
  244. $(".localisation").after("<ul class='form-errors'><li>Veuillez renseigner ce champ.</li></ul>");
  245. } else {
  246. $(".localisation").after("<ul class='form-errors'><li>Veuillez sélectionner une ville et un code postal valides.</li></ul>");
  247. }
  248. if (form_demande_validated) {
  249. console.log('.localisation')
  250. $(".localisation").focus();
  251. $('html, body').animate({ scrollTop: $('.localisation').offset().top - 110}, 50);
  252. }
  253. form_demande_validated = false;
  254. }
  255. $("form select[required]:visible:not(#demande_bienType)").each(function () {
  256. if (!$(this).val() || $(this).val() == '') {
  257. $(this).parent(".select-background").after("<ul class='form-errors'><li>Veuillez renseigner ce champ.</li></ul>");
  258. if (form_demande_validated) {
  259. console.log("element select", this)
  260. this.setCustomValidity("Veuillez renseigner ce champ.");
  261. $(this).focus();
  262. $('html, body').animate({ scrollTop: $(this).parent(".select-background").offset().top - 110}, 50);
  263. }
  264. form_demande_validated = false;
  265. } else {
  266. this.setCustomValidity("");
  267. }
  268. })
  269. $("form input[required]:visible").each(function () {
  270. if (
  271. !$(this).is(".localisation")
  272. && (
  273. !$(this).val()
  274. || $(this).val() == ''
  275. || ($(this).is('checkbox') && !$(this).is(':checked')))
  276. )
  277. {
  278. $(this).after("<ul class='form-errors'><li>Veuillez renseigner ce champ.</li></ul>");
  279. if (form_demande_validated) {
  280. this.setCustomValidity("Veuillez renseigner ce champ.");
  281. $(this).focus();
  282. $('html, body').animate({ scrollTop: $(this).offset().top - 110}, 50);
  283. }
  284. form_demande_validated = false;
  285. } else { this.setCustomValidity(""); }
  286. });
  287. if ($("#demande_clientEmail").val() && $("#demande_clientEmail").val() != "") {
  288. var regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
  289. if (!regex.test($("#demande_clientEmail").val())) {
  290. $("#demande_clientEmail").after("<ul class='form-errors'><li>Veuillez saisir un email valide.</li></ul>");
  291. if (form_demande_validated) {
  292. $("#demande_clientEmail").focus();
  293. $('html, body').animate({ scrollTop: $("#demande_clientEmail").offset().top - 110}, 50);
  294. }
  295. form_demande_validated = false;
  296. }
  297. }
  298. var phone = $("#demande_clientTelephone").val();
  299. phone = phone.replaceAll(" ", "");
  300. $('#demande_clientTelephone').val(phone);
  301. phone = $("#demande_clientTelephone").val();
  302. // Supprimer les espaces et les caractères spéciaux
  303. const numeroNettoye = phone.replace(/[^0-9]/g, '');
  304. // Liste noire de numéros spécifiques (Set pour des performances optimales)
  305. const blacklist = new Set([
  306. '0000000000', '1111111111', '2222222222',
  307. '3333333333', '4444444444', '5555555555',
  308. '6666666666', '7777777777', '8888888888',
  309. '9999999999', '0123456789', '0987654321'
  310. ]);
  311. // Liste des motifs spéciaux interdits
  312. const motifsSpeciaux = [
  313. '0101010101', '0202020202', '0303030303',
  314. '0404040404', '0505050505', '0606060606',
  315. '0707070707', '0909090909'
  316. ];
  317. // Vérifier la longueur (10 chiffres)
  318. if (
  319. blacklist.has(numeroNettoye)
  320. || (numeroNettoye.length !== 0 && numeroNettoye.length !== 10)
  321. || (numeroNettoye.length !== 0 && !/^0[1-79]/.test(numeroNettoye))
  322. || motifsSpeciaux.includes(numeroNettoye)
  323. || /(\d)\1{7,}|^(\d)\1{9}$/.test(numeroNettoye)
  324. || /(\d{2})\1{3,}/.test(numeroNettoye)
  325. ) {
  326. $("#demande_clientTelephone").after("<ul class='form-errors'><li>Veuillez saisir un téléphone valide.</li></ul>");
  327. if (form_demande_validated) {
  328. $('#demande_clientTelephone').focus();
  329. $('html, body').animate({ scrollTop: $('#demande_clientTelephone').offset().top - 110}, 50);
  330. }
  331. form_demande_validated = false;
  332. }
  333. const submitButton = $("form button");
  334. if (form_demande_validated) {
  335. submitButton.prop('disabled', true);
  336. submitButton.text('Envoi en cours…');
  337. $('form').submit();
  338. }
  339. return form_demande_validated;
  340. }
  341. </script>