Form Validation Using JavaScript

How to Validate HTML Form Using Javascript?

I had a form where I needed to put a condition “Either email or phone number should be inserted”.

A name was compulsory to add, so  I have added ‘required’ keyword in name field. But for Email and phone number validation I used javascript code.

Following is the code.

Create a file and save it with .html extension.

 

<form method="post" name="contactform" onsubmit="return validateForm()">
<input class="form-field" type="text" name="name" id="name" value="" placeholder="Name *" required>
<input class="form-field" type="text" name="phone" id="phone" value="" placeholder="Phone *">
<input class="form-field" type="email" name="email" id="email" value="" placeholder="Email *">
<input class="form-field " type="text" name="pincode" id="pincode" value="" placeholder="Postal Code *">
<textarea class="form-field form-field-comment" name="comments" placeholder="Comments"></textarea>
<input type="checkbox" name="agree" required style="margin-bottom: 0;">
<label for="" style="display: inline">I agree to accept <a href="<?php echo base_url(); ?>privacy-policy/">terms and conditions</a></label>
<div class="form-btn-shadow">

<div class="form-btn">

<div><button class="form-btn-item">Submit</button></div>

</div>
</form>

<script type="text/javascript">
function validateForm() {
var x = document.forms["contactform"]["phone"].value;
var y = document.forms["contactform"]["email"].value;
if (y == "" || x == "") {
alert("Email or Phone must be filled out");
return false;
}

}
</script>

 

278 thoughts on “Form Validation Using JavaScript

  1. Pingback: Google
  2. Pingback: Google
  3. Pingback: 토토사이트
  4. Pingback: 사다리사이트
  5. Pingback: 안전놀이터
  6. Pingback: 먹튀검증
  7. Pingback: silicone massagers
  8. Pingback: double dong
  9. Pingback: beast tv apk
  10. Pingback: big dildo
  11. Pingback: 안전공원
  12. Pingback: 토토사이트
  13. Pingback: xnnx
  14. Pingback: broncos
  15. Pingback: Deals on goods
  16. Pingback: FIFA Coins
  17. Pingback: flexible vibrator
  18. Pingback: Detroit SEO
  19. Pingback: detox tea
  20. Pingback: shmmovers
  21. Pingback: cursos online
  22. Pingback: body wand
  23. Pingback: dp cock ring
  24. Pingback: music theory
  25. Pingback: Click Here
  26. Pingback: chwilówki
  27. Pingback: mobile repair
  28. Pingback: bullet egg
  29. Pingback: wild orchid toy
  30. Pingback: adam and eve dildo
  31. Pingback: Porn City XXX
  32. Pingback: penis masturbator
  33. Pingback: prostate vibrator
  34. Pingback: Nerf Gun
  35. Pingback: mail order brides
  36. Pingback: anal sex toys
  37. Pingback: Ravishing Rabbit
  38. Pingback: Lawn
  39. Pingback: penis enlarger
  40. Pingback: vibrating dildo
  41. Pingback: fun88
  42. Pingback: 188bet
  43. Pingback: женка
  44. Pingback: pc games download
  45. Pingback: cameras ao vivo
  46. Pingback: anal cleaning
  47. Pingback: pocket masturbator
  48. Pingback: Piz Buin
  49. Pingback: bodyboards
  50. Pingback: app for pc
  51. Pingback: pc games download
  52. Pingback: nipple clamp
  53. Pingback: Gurgaon
  54. Pingback: cursos gratuitos
  55. Pingback: filles coquin
  56. Pingback: shemale sexdate
  57. Pingback: top thrusting toy
  58. Pingback: realistic dong
  59. Pingback: realistic stroker
  60. Pingback: sm n920tzkatmb
  61. Pingback: sex toys
  62. Pingback: gay anal vibrator
  63. Pingback: gay dildo
  64. Pingback: room tour
  65. Pingback: vibrator set
  66. Pingback: wall mounted dildo
  67. Pingback: Pornland
  68. Pingback: jelly anal plug
  69. Pingback: easy payday loans
  70. Pingback: Tadapox
  71. Pingback: dong
  72. Pingback: dildo reviews
  73. Pingback: vaginal balls
  74. Pingback: erotic vibrator
  75. Pingback: big dildo review
  76. Pingback: sex games
  77. Pingback: kegels benefits
  78. Pingback: cock ring review
  79. Pingback: Oliver Isaacs
  80. Pingback: satta matka
  81. Pingback: remote bullet vibe
  82. Pingback: clit vibe
  83. Pingback: best pocket pussy
  84. Pingback: dildo reviews
  85. Pingback: anal plug kit
  86. Pingback: porn city
  87. Pingback: bondage restraints
  88. Pingback: porn land
  89. Pingback: penis vibrator
  90. Pingback: jockstrap try on
  91. Pingback: cyberskin stroker
  92. Pingback: kitchens designs
  93. Pingback: male stroker toy
  94. Pingback: ssru.ac.th
  95. Pingback: rabbit vibrators
  96. Pingback: big dong
  97. Pingback: realistic dildo
  98. Pingback: cool vibrators
  99. Pingback: vibrating egg
  100. Pingback: bondage set
  101. Pingback: Pen kopen
  102. Pingback: suction cup dildo
  103. Pingback: sex costume
  104. Pingback: go to this site
  105. Pingback: Julia Ann Porn
  106. Pingback: bdjobs ngo
  107. Pingback: Pakistani Suits
  108. Pingback: sexboer
  109. Pingback: geile sex filmpjes
  110. Pingback: porno files
  111. Pingback: pornofilmpjes
  112. Pingback: gratis films
  113. Pingback: liteblue
  114. Pingback: порскать
  115. Pingback: кварты
  116. Pingback: Penis Pump Video
  117. Pingback: Hundetæppe
  118. Pingback: walmartone login
  119. Pingback: Bluechew reviews
  120. Pingback: gay porn
  121. Pingback: Don Karl Juravin
  122. Pingback: bondage equipment
  123. Pingback: mcdonalds hours
  124. Pingback: anal lubricant
  125. Pingback: bullet vibrator
  126. Pingback: podcast
  127. Pingback: dominoqq
  128. Pingback: deposit qq poker
  129. Pingback: BWI transportation
  130. Pingback: how to deep throat
  131. Pingback: mens pleasure ring
  132. Pingback: home decor books
  133. Pingback: daftar maxbet
  134. Pingback: rod power vibrator
  135. Pingback: free hacks 2018
  136. Pingback: AOL Mail Login
  137. Pingback: hasta karyolası
  138. Pingback: سکس خارجی
  139. Pingback: seashell jewelry
  140. Pingback: döner hamburg
  141. Pingback: doc johnson

Leave a Reply