Пример #1
0
		void noFacebookSignup2SaveClick(jQueryEvent e)
		{
			e.PreventDefault();

			if (AsyncInProgress)
				return;

			View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "";

			#region Check name
			if (View.Connect_LoggedOut_NoFacebook_SignUp2_FirstNameTextbox.Value.Length == 0)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your first name";
				return;
			}

			if (View.Connect_LoggedOut_NoFacebook_SignUp2_LastNameTextbox.Value.Length == 0)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your last name";
				return;
			}

			if (View.Connect_LoggedOut_NoFacebook_SignUp2_FirstNameTextbox.Value.Length > 20)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "First name is too long";
				return;
			}

			if (View.Connect_LoggedOut_NoFacebook_SignUp2_LastNameTextbox.Value.Length > 20)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Last name is too long";
				return;
			}
			#endregion

			#region Check nickname
			if (View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value.Length == 0)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter a nickname";
				return;
			}

			if (View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value.Length < 2)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Nickname must be longer";
				return;
			}

			if (View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value.Length > 20)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Nickname is too long";
				return;
			}
			#endregion

			#region Check date of birth
			if (int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown.Value) < 0 ||
				int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown.Value) < 0 ||
				int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown.Value) < 0)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your date of birth";
				return;
			}

			Date d = new Date();
			d.SetFullYear(int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown.Value));
			d.SetMonth(int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown.Value));
			d.SetDate(int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown.Value));

			if (d.GetFullYear() != int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthYearDropDown.Value) ||
				d.GetMonth() != int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthMonthDropDown.Value) ||
				d.GetDate() != int.Parse(View.Connect_LoggedOut_NoFacebook_SignUp2_DateOfBirthDayDropDown.Value))
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Check your date of birth";
				return;
			}
			#endregion

			#region Check sex
			if (!View.Connect_LoggedOut_NoFacebook_SignUp2_SexMaleRadio.Checked && !View.Connect_LoggedOut_NoFacebook_SignUp2_SexFemaleRadio.Checked)
			{
				View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "Enter your sex";
				return;
			}
			#endregion

			#region Check nickname
			int thisAsyncOperation = RegisterStartAsync("Checking nickname...");
			Server.GetUniqueNickName(
				View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value,
				NoFacebookSignUp2PanelLoginUsrK,
				new Response(
					delegate(Dictionary<object, object> response)
					{
						if (RegisterEndAsync(thisAsyncOperation))
							return;

						if (U.isTrue(response, "Exception"))
						{
							showError(7, "Internal server error");
						}
						else
						{
							string newNickname = U.get(response, "Nickname").ToString();
							if (View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value != newNickname)
							{
								View.Connect_LoggedOut_NoFacebook_SignUp2_NicknameTextbox.Value = newNickname;
								View.Connect_LoggedOut_NoFacebook_SignUp2_ErrorLabel.InnerHTML = "We changed your nickname. Is this OK?";
								return;
							}
							else
							{
								noFacebookSignup2SaveDone();
							}
						}
					}
				)
			);
			#endregion
			
		}