コード例 #1
0
        ///
        /// <summary>   Event handler. Called by PNumberTextBox for text changed events. </summary>
        ///
        /// <remarks>   2019-04-20. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        Text changed event information. </param>
        ///

        private void PNumberTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            bool isValid = true;

            //Phone number validation
            isValid = PatientValidation.ValidatePhone(pNumberTextBox.Text);

            if (!isValid && !String.IsNullOrEmpty(pNumberTextBox.Text)) //Not valid and not empty
            {
                pNumberBool          = false;
                pNumError.Visibility = Visibility.Visible;
            }
            else //Valid
            {
                pNumberBool          = true;
                pNumError.Visibility = Visibility.Hidden;
            }
        }
コード例 #2
0
        /// <summary>   Event handler. Called by PNumberTextBox for text changed events.
        ///             Ensure valid phone number entry </summary>
        ///
        /// <remarks>   2019-04-20. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        Text changed event information. </param>

        private void PNumberTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            SubmitError.Visibility = Visibility.Hidden; //Hide the error initally
            bool isValid = true;

            //Check phone validation
            isValid = PatientValidation.ValidatePhone(pNumberTextBox.Text);

            if (!isValid && !String.IsNullOrEmpty(pNumberTextBox.Text)) //see if not valid and string is not empty
            {
                //Set phone value to nothing. Show the error
                phoneNum             = "";
                pNumError.Visibility = Visibility.Visible;
            }
            else //Valid. Set phone value to textbox value. Hide the error
            {
                phoneNum             = pNumberTextBox.Text;
                pNumError.Visibility = Visibility.Hidden;
            }
        }