| 12
 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
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 
 | $(document).ready(function(){
				$("#accept").click(function(){
					if($("#ok").attr("checked")){//
 
						$.ajax( 
							{ 
								type: "POST",
								dataType: "html", 
								url: "step.php", 
								data: "do=reg&ok=1", 
								success: function(res){ 
									$('#form_step').empty(); //
									$('#form_step').append(res); 
								} 
							}	
						)
					}else{
						$('span#termsmsg').css("display", "inline").text('You must accept the terms of use');
					}
				}); 
				$("#ok").change( function() {$("#termsmsg").empty(); } );
 
 
				$.validator.addMethod(
					"regex",
					function(value, element, regexp) {
						if (regexp.constructor != RegExp)
							regexp = new RegExp(regexp);
						else if (regexp.global)
							regexp.lastIndex = 0;
						return this.optional(element) || regexp.test(value);
					},"Please check your input.");
 
 
				jQuery.validator.addMethod("accept", function(value, element, param) {
					return value.match(new RegExp("." + param + "$"));
					},jQuery.format("Only {0} extentions are allowed"));
 
				// bind a callback to the step_shown event
				$("#demoForm").bind("step_shown", function(event, data){
					$("#step_visualization").html("");
 
					/*if(data.isBackNavigation || !data.isFirstStep){
						var direction = (data.isBackNavigation)?"back":"forward";
						$("#step_visualization").append("<div>Moving "+ direction +"</div>");
					}*/
					$.each(data.activatedSteps, function(i,sval){
						$("#step_visualization").append("<span class=\"visualization\" id=\"visualization_" + this + "\">" + i + " : " + sval + "</span> ")
 
						switch (i){
						case -1 :
								//$('span#step3').removeClass('active').addClass('passive');
								//$('span#step1').removeClass('passive').addClass('active');
								var username = $('#username').val(),
								password= $('#password').val(),
								confirm_password = $('#confirm_password').val(),
								email = $('#email').val(),
								code = $('#code').val();	
 
								var parametre = "action=step2&username="+username+"&password="+password+"&email="+email+"&code="+code;
								$("#step2").removeClass('active').addClass('passive');
								$("#step3").removeClass('passive').addClass('active');
								$.ajax( 
										{ 
											type: "POST",
											dataType: "html", 
											url: "step.php", 
											data: "do=reg"+parametre, 
											success: function(res){ 
														$('#form_step').empty(); //
														$('#form_step').append(res); 
													} 
										}	
									)
 
						break;		
						case 1 :
								$('span#step3').removeClass().addClass('passive');
								$('span#step1').removeClass('passive').addClass('active');
						break;		
						case 2 :
								$('span#step1').removeClass('active').addClass('passive');
								$('span#step2').removeClass('passive').addClass('active');
						break;
						case 3 :
								$('span#step2').removeClass('active').addClass('passive');
								$('span#step3').removeClass('passive').addClass('active');
						break;
 
						}
 
					});
					/*
						Available data:
						isBackNavigation - boolean
						settings - options object containing the options set for the wizard
						activatedSteps - list of activated steps (visited steps)
						isLastStep - boolean specifying whether the current step is a submit step
						isFirstStep - boolean
						previousStep - the id of the previously visited step
						currentStep - the id of the current step
						backButton
						nextButton
						steps - the steps of the wizard 
						firstStep - the id of the first step
					*/
 
				})
 
				$("input.#countryPrefix").mask("+999");
				$("input#phoneNumber").mask("99.99.99");
				$("input#areaCode").mask("(999)");
				$("input.zipcode").mask("99999");
 
				////**********//////
 
				$("#demoForm").formwizard({ 
				 	formPluginEnabled: true,
				 	validationEnabled: true,
				 	focusFirstInput : true,
				 	formOptions :{
						success: function(data){$("#status").fadeTo(500,1,function(){ $(this).html("You are now registered!").fadeTo(5000, 0); })},
						beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
						dataType: 'step.php',
						resetForm: true
				 	},
				 	validationOptions : {
				 		rules: {
							ok : "required",
							username: {
								required: true,
								minlength: 3,
								maxlength:10,
								regex: /^[a-zA-Z0-9._-]+$/i,
								remote: {
									url: "user_unique.php",
									type: "post",
									dataType: "html", 
									data: 
									{
										username: function() {
											return $("#username").val();
										}
									},
									success: function(msg1){ 
 
										$("#note1").empty();
										if(msg1 == 'no') // Message Sent? 
												{
													$("#note1").append($("#username").val()+" is not available").css("display","inline");
												}else{
													$("#note1").append($("#username").val()+" is available").css("dispaly","inline");	
												}
												//$(this).html(result);
 
									}
								}		
 
							},
							password: {
								required: true,
								minlength: 4
								},
							confirm_password: {
								required: true,
								minlength: 4,
								equalTo: "#password"
								},
							email: {
								required: true,
								email: true,
								remote: {
									url: "email_unique.php",
									type: "post",
									dataType: "html", 
									data: {
										email: function(data) {
											return $("#email").val();
										}
									},	
									success: function(msg2){ 
										$("#note2").empty();
										if(msg2 == 'no') // Message Sent? 
											{
													$("#note2").append($("#email").val()+" is not available").css("display","inline");
											}else{
													$("#note2").append($("#email").val()+" is available").css("display","inline");	
											}
										} 
								}
							},
 
							country: {
							    required: true
								},
							//phoneNumber: { required: true, regex : /^[\d\s]+$/, minlength: 10 },
							pic: { accept: "(jpe?g|gif|png)" },
							terms: "required",
							firstname : {regex: /^[a-zA-Z0-9._-]+$/i},
							surname : {regex: /^[a-zA-Z0-9._-]+$/i},
						},
 
						messages: {
							ok:"you must agree the terms",
							username: {
								required: "Please enter a username",
								maxlength:"max length 10 letters",
								minlength: "Your username must consist of at least 3 characters",
								regex: "No special caracteres are allowed",
								//remote: jQuery.format("{0} is already in use")
								},
							password: {
								required: "Please provide a password",
								minlength: "Your password must be at least 4 characters long"
								},
							confirm_password: {
								required: "Please provide a confirm password",
								minlength: "Your password must be at least 4 characters long",
								equalTo: "Please enter the same password as above"
								},
							country: "Please specify your country",
							email: {
								required: "Please specify your email",
								email: "Correct format is name@domain.com",
								//remote: jQuery.format("{0} is already in use")
								},
							firstname: {regex: "No special caracteres are allowed"},
							surname: {regex: "No special caracteres are allowed"},
							pic : jQuery.format("Only {0} extention are allowed")
 
						}
					}
				});
 
				/***********************/
 
	}); | 
Partager