Bonjour,

J'utilise un script MailHandler et je bloque depuis 2 jours sur les champs non obligatoires ...

Certains champs sont obligatoires, d'autres non. Je teste le formulaire, je ne remplie que les parties requises et laisse les champs facultatifs vides, je valide et rien ne se passe, par contre, si je remplie tous les champs, le formulaire est bien envoyé. J'en déduis donc que toutes les parties sont obligatoires et que cela doit se passer au niveau du fichier.js.
Si vous pourriez m'aider à y voir plus clair ..

Comment faire en sorte que les champs : "couleur 2, couleur 3, précisez, boutons et autres" puissent rester vides lors de l'envoi du formulaire ?

Merci par avance

form.js :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
(function($){
	$.fn.extend({
		forms:function(opt){
			if(opt===undefined)
				opt={}
			this.each(function(){
				var th=$(this),
					data=th.data('forms'),
					_={
						errorCl:'error',
						emptyCl:'empty',
						invalidCl:'invalid',
						successCl:'success',
						successShow:'4000',
						mailHandlerURL:'template/bin/MailHandler.php',
						ownerEmail:'mon adresse email',
						stripHTML:true,
						smtpMailServer:'smtp.sfr.fr',
						targets:'input,textarea',
						controls:'a[data-type=reset],a[data-type=submit]',
						validate:true,
						rx:{
							".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
							".prenom":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
							".sujet":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
							".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
							".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
							".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
							".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
							".couleurprincipale":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".logo":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".titre":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".soustitre":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".texte":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".liens":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".lienssurvoles":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".liensvisites":{rx:/^\+?(\d[\d\-\+\(\) ]{1,}\d$)/,target:'input'},
							".message":{rx:/.{20}/,target:'textarea'}
						},
						preFu:function(){
							_.labels.each(function(){
								var label=$(this),
									inp=$(_.targets,this),
									defVal=inp.val(),
									trueVal=(function(){
												var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html()
												return defVal==''?defVal:tmp
											})()
								trueVal!=defVal
									&&inp.val(defVal=trueVal||defVal)
								label.data({defVal:defVal})								
								inp
									.bind('focus',function(){
										inp.val()==defVal
											&&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl))
									})
									.bind('blur',function(){
										!inp.val()
											?inp.val(defVal)										
											:(_.isValid(label)
												?_.showErrorFu(label)
												:_.hideErrorFu(label)),
											(_.isEmpty(label)
												?_.showEmptyFu(label)
												:_.hideEmptyFu(label))
									})
									.bind('keyup',function(){
										label.hasClass(_.invalidCl)
											&&_.isValid(label)
												?_.showErrorFu(label)
												:_.hideErrorFu(label)
									})
								label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide()
							})
							_.success=$('.'+_.successCl,_.form).hide()
						},
						isValid:function(el){
							var ret=true,
								empt=_.isEmpty(el)
							if(empt)
								ret=false,
								el.addClass(_.invalidCl)
							else
								$.each(_.rx,function(k,d){
									if(el.is(k))
										d.rx.test(el.find(d.target).val())
											?(el.removeClass(_.invalidCl),ret=false)
											:el.addClass(_.invalidCl)
								})
							return ret
						},
						isEmpty:function(el){
							var tmp
							return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal')
						},
						validateFu:function(){							
							_.labels.each(function(){
								var th=$(this)								
								_.isEmpty(th)
									?_.showEmptyFu(th)
									:_.hideEmptyFu(th)
								_.isValid(th)
									?_.showErrorFu(th)
									:_.hideErrorFu(th)
							})
						},
						submitFu:function(){
							_.validateFu()
							if(!_.form.has('.'+_.invalidCl).length)
								$.ajax({
									type: "POST",
									url:_.mailHandlerURL,
									data:{
										name:$('.name input',_.form).val()||'nope',
										prenom:$('.prenom input',_.form).val()||'nope',
										sujet:$('.sujet input',_.form).val()||'nope',
										email:$('.email input',_.form).val()||'nope',
										phone:$('.phone input',_.form).val()||'nope',
										fax:$('.fax input',_.form).val()||'nope',
										couleurprincipale:$('.couleurprincipale input',_.form).val()||'nope',
										couleur2:$('.couleur2 input',_.form).val()||'nope',
										couleur3:$('.couleur3 input',_.form).val()||'nope',
										state:$('.state input',_.form).val()||'nope',
										logo:$('.logo input',_.form).val()||'nope',
										logo2:$('.logo2 input',_.form).val()||'nope',
										titre:$('.titre input',_.form).val()||'nope',
										soustitre:$('.soustitre input',_.form).val()||'nope',
										texte:$('.texte input',_.form).val()||'nope',
										boutons:$('.boutons input',_.form).val()||'nope',
										liens:$('.liens input',_.form).val()||'nope',
										lienssurvoles:$('.lienssurvoles input',_.form).val()||'nope',
										liensvisites:$('.liensvisites input',_.form).val()||'nope',
										precise1:$('.precise1 textarea',_.form).val()||'nope',
										precise2:$('.precise2 textarea',_.form).val()||'nope',
										precise3:$('.precise3 textarea',_.form).val()||'nope',
										autres:$('.autres textarea').val()||'nope',
										message:$('.message textarea',_.form).val()||'nope',
										owner_email:_.ownerEmail,
										stripHTML:_.stripHTML
									},
									success: function(){
										_.showFu()
									}
								})			
						},
						showFu:function(){
 
							_.success.slideDown(function(){
								setTimeout(function(){
									_.success.slideUp()
									_.form.trigger('reset')
								},_.successShow)
							})
						},
						controlsFu:function(){
							$(_.controls,_.form).each(function(){
								var th=$(this)
								th
									.bind('click',function(){
										_.form.trigger(th.data('type'))
										return false
									})
							})
						},
						showErrorFu:function(label){
							label.find('.'+_.errorCl).slideDown()
						},
						hideErrorFu:function(label){
							label.find('.'+_.errorCl).slideUp()
						},
						showEmptyFu:function(label){
							label.find('.'+_.emptyCl).slideDown()
							_.hideErrorFu(label)
						},
						hideEmptyFu:function(label){
							label.find('.'+_.emptyCl).slideUp()
						},
						init:function(){
							_.form=this
							_.labels=$('label',_.form)
 
							_.preFu()
 
							_.controlsFu()
 
							_.form
								.bind('submit',function(){
									if(_.validate)
										_.submitFu()
									else
										_.form[0].submit()
									return false
								})
								.bind('reset',function(){
									_.labels.removeClass(_.invalidCl)									
									_.labels.each(function(){
										var th=$(this)
										_.hideErrorFu(th)
										_.hideEmptyFu(th)
									})
								})
							_.form.trigger('reset')
						}
					}
				if(!data)
					(typeof opt=='object'?$.extend(_,opt):_).init.call(th),
					th.data({cScroll:_}),
					data=_
				else
					_=typeof opt=='object'?$.extend(data,opt):data
			})
			return this
		}
	})
})(jQuery)
$(function(){
	$('#contact-form').forms({
		ownerEmail:'mon adresse email'
	})
	$('#main-newsletter-form').forms({
		ownerEmail:'mon adresse email'
	})
})
form.html

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<form id="contact-form">
<div class="success"> ::messageenvoye::</div>
  <fieldset>
    <label class="name">::votrenom:: <font color="#FF0000">*</font>
    <input type="text" class="formbox" name="name" value=""/>
    <span class="errors"><span class="error">::nomobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>
    <label class="email">::votreemail:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="email" value=""/>
    <span class="errors"><span class="error">::emailobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>
    <label class="couleurprincipale">::couleurprincipale:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="couleurprincipale" value=""/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label> 
    <label class="precise1">::precise::
    <textarea class="messagebox"></textarea>
    </label>
    <label class="couleur2">::couleur2::
	<input type="text" class="formbox" name="couleur2" value=""/>
    </label>
    <label class="precise2">::precise::
    <textarea class="messagebox"></textarea>
    </label>
    <label class="couleur3">::couleur3::
	<input type="text" class="formbox" name="couleur3" value=""/>
    </label>
    <label class="precise3">::precise::
    <textarea class="messagebox"></textarea>
    </label>
    <label class="logo">::logo:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="logo" value="::logocouleur1::"/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>  
     <label class="logo2">
	<input type="text" class="formbox" name="logo2" value="::logocouleur2::"/>
    </label>  
    <label class="titre">::titrecouleur:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="titre" value=""/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label> 
    <label class="soustitre">::soustitrecouleur:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="soustitre" value=""/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>   
    <label class="texte">::textescouleur:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="texte" value=""/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>
     <label class="boutons">::boutons::
	<input type="text" class="formbox" name="boutons" value=""/>
    </label>
    <label class="liens">::lienhypertexte:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="liens" value=""/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>	
    <label class="lienssurvoles">::lienssurvoles:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="lienssurvoles" value=""/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>	
    <label class="liensvisites">::liensvisites:: <font color="#FF0000">*</font>
	<input type="text" class="formbox" name="liensvisites" value=""/>
    <span class="errors"><span class="error">::couleurobligatoire::</span> <span class="empty">::champobligatoire::</span></span>
    </label>
    <label class="autres">::autres::
    <textarea class="messagebox">::plusprecision::</textarea>
    </label>				
    <div class="btns">
    <a data-type="submit">::envoyer::</a>
    <a data-type="reset">::rafraîchir::</a>
    </div>
    <p>&nbsp;</p>
    <p>::champsobligatoires::</p>
  </fieldset> 
</form>