Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Xamarin.Forms;
  7. using Plugin.Messaging;
  8. using System.Text.RegularExpressions;
  9. using Basic.Models;
  10.  
  11. namespace Basic
  12. {
  13. public partial class MainPage : ContentPage
  14. {
  15. public MainPage()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void SmsButton_Clicked(object sender, EventArgs e)
  21. {
  22. try
  23. {
  24. var MObNo = entry_no.Text;
  25. var mobileNoPattern = @"^[+1-9][0-9]{12}$";
  26.  
  27. if (Regex.IsMatch((entry_no.Text), mobileNoPattern))
  28. {
  29. var PhoneCall = CrossMessaging.Current.PhoneDialer;
  30.  
  31. if (PhoneCall.CanMakePhoneCall)
  32. {
  33. Device.OpenUri(new Uri("tel:" + MObNo));
  34. // PhoneCall.MakePhoneCall(MObNo);
  35. }
  36. }
  37. else
  38. {
  39. // await DisplayAlert("Hey", "Enter correct mobile No.", "OK");
  40. MobileError _mobileerroe = new MobileError();
  41. _mobileerroe.lblError = "Mobile No not Valid";
  42. BindingContext = _mobileerroe;
  43. }
  44. }
  45. catch
  46. {
  47. //await DisplayAlert("Hey", "Enter mobile No.", "OK");
  48. MobileError _mobileerror = new MobileError();
  49. _mobileerror.lblError = "Mobile No not Valid";
  50. BindingContext = _mobileerror;
  51. }
  52. }
  53.  
  54. private void entry_no_TextChanged(object sender, TextChangedEventArgs e)
  55. {
  56. string _text = entry_no.Text;
  57. if (_text.Length > 13)
  58. {
  59. _text = _text.Remove(_text.Length - 1);
  60. entry_no.Text = _text;
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement