Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. <form action=demo.php method="post">
  2. <div >
  3. <label class="control-label" for="email">Your email address/Mobile number</label>
  4. <div class="controls">
  5. <input type="email" name="email" required />
  6.  
  7. </div>
  8. </div>
  9.  
  10. <input type="submit" name="submit">Submit</button>
  11. </form>
  12.  
  13. function validateEmail() {
  14. var email = document.getElementById('txtEmail');
  15. var mailFormat = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})|([0-9]{10})+$/;
  16. if (email.value == "") {
  17. alert( " Please enter your Email or Phone Number ");
  18. }
  19. else if (!mailFormat.test(email.value)) {
  20. alert( " Email Address / Phone number is not valid, Please provide a valid Email or phone number ");
  21. return false;
  22. }
  23. else {
  24. alert(" Success ");
  25. }
  26. }
  27.  
  28. <script>
  29. $(document).ready(function () {
  30. $("#cuntryCode").hide();
  31. $("#useridInput").on('input', function () {
  32. var len = $("#useridInput").val().length;
  33. if (len >= 2) {
  34. var VAL = this.value;
  35. var intRegex = /^[1-9][0-9]*([.][0-9]{2}|)$/;
  36. if (!intRegex.test(VAL)) {
  37. $('#error-caption').html('Invalid email. Please check spelling.');
  38. $('#error-caption').css('color', 'red');
  39. $("#cuntryCode").hide();
  40. } else {
  41. if(len < 10){
  42. $('#error-caption').html('Invalid mobile number. Please try again.');
  43. $('#error-caption').css('color', 'red');
  44. $("#cuntryCode").show();
  45. }else{
  46. $('#error-caption').html('Invalid mobile number. length must be 10 digit.');
  47. $('#error-caption').css('color', 'red');
  48. }
  49. }
  50. }else{
  51. $("#cuntryCode").hide();
  52. $('#error-caption').html('');
  53. }
  54.  
  55. });
  56. });
  57.  
  58. </script>
  59.  
  60.  
  61.  
  62. <form class="push--top-small forward" method="POST" data-reactid="15">
  63. <h4 id="input-title" data-reactid="16">Welcome back
  64. </h4>
  65. <label class="label" id="input-label" for="useridInput" data-reactid="17">Sign in with your email address or mobile number.
  66. </label>
  67. <div style="margin-bottom:24px;" data-reactid="18">
  68. <div >
  69. <div id="cuntryCode" class="_style_4kEO6r" style="float: left; height: 44px; line-height: 44px;">
  70. <div tabindex="0" > +241
  71. </div>
  72. </div>
  73. <div style="display:flex;">
  74. <input id="useridInput" autocorrect="off" autocapitalize="off" name="textInputValue" class="text-input" placeholder="Email or mobile number" aria-required="true" aria-invalid="false" aria-describedby="error-caption input-title">
  75. </div>
  76. </div>
  77. <div id="error-caption">
  78. </div>
  79. </div>
  80. <button class="btn btn--arrow btn--full" data-reactid="24">
  81. <span class="push-small--right" data-reactid="25">Next
  82. </span>
  83. </button>
  84. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement