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>

 

623 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
  142. Pingback: YtMp3
  143. Pingback: gay men with toys
  144. Pingback: Baccarat System
  145. Pingback: one walmart
  146. Pingback: domain
  147. Pingback: anal training plug
  148. Pingback: anal plug set
  149. Pingback: Follower
  150. Pingback: Ghana News
  151. Pingback: best anal douches
  152. Pingback: 192.168.1.1/
  153. Pingback: adult lingerie
  154. Pingback: Virtual Card buy
  155. Pingback: btc to neteller
  156. Pingback: realistic dildo
  157. Pingback: how to do anal
  158. Pingback: men in jockstraps
  159. Pingback: easy guitar licks
  160. Pingback: male masturbator
  161. Pingback: pc app
  162. Pingback: فیلم سوپر
  163. Pingback: Eweka
  164. Pingback: Minyak Kelapa
  165. Pingback: numb spray
  166. Pingback: school grants
  167. Pingback: mywalmart schedule
  168. Pingback: kingpen
  169. Pingback: لعبه
  170. Pingback: exotic carts pen
  171. Pingback: 710 king pen
  172. Pingback: Dank Vapes
  173. Pingback: THC vape juice
  174. Pingback: Generic Cialis
  175. Pingback: Tramadol Sale
  176. Pingback: walmart1
  177. Pingback: EBOD-710
  178. Pingback: T shirts
  179. Pingback: Women clothing
  180. Pingback: 618media.com
  181. Pingback: prostate milking
  182. Pingback: Ioe news
  183. Pingback: latest jobs Canada
  184. Pingback: best jockstrap
  185. Pingback: sex restraints
  186. Pingback: lube for anal sex
  187. Pingback: IPX 363
  188. Pingback: butt douching
  189. Pingback: jelly vibrator
  190. Pingback: SEO Vancouver
  191. Pingback: PPPD-789
  192. Pingback: daftar joker123
  193. Pingback: milfgilf xxx
  194. Pingback: XVSR-499
  195. Pingback: sewa led
  196. Pingback: Lamelo ball
  197. Pingback: عرب نار
  198. Pingback: giant dildo
  199. Pingback: nipple suckers
  200. Pingback: hotmail.com login
  201. Pingback: sneaker
  202. Pingback: فیلم سکسی
  203. Pingback: laptop app
  204. Pingback: finde freunde
  205. Pingback: brochure maker
  206. Pingback: web developer
  207. Pingback: MIAA-159
  208. Pingback: txxx
  209. Pingback: THC vape juice
  210. Pingback: vape tanks
  211. Pingback: Leora Adkisson
  212. Pingback: DOCP 173
  213. Pingback: stretchy cock ring
  214. Pingback: double dildo
  215. Pingback: penis ring review
  216. Pingback: Oxycodone for sale
  217. Pingback: bullet massager
  218. Pingback: virtual debit card
  219. Pingback: tv shows
  220. Pingback: jewelry stores
  221. Pingback: app apk for pc
  222. Pingback: Smm panel paypal
  223. Pingback: free app download
  224. Pingback: info
  225. Pingback: cannabis for sale
  226. Pingback: strapon
  227. Pingback: anal sex toys
  228. Pingback: asmr tapping
  229. Pingback: Prestige Waterford
  230. Pingback: buy viagra
  231. Pingback: viagra
  232. Pingback: Xenon XP
  233. Pingback: women with tattoo
  234. Pingback: hitachi magic wand
  235. Pingback: viagra
  236. Pingback: buy cbd oil
  237. Pingback: cbd oil for sale
  238. Pingback: cbd for sale
  239. Pingback: cialis
  240. Pingback: vibrator
  241. Pingback: adam and eve dildo
  242. Pingback: vibrator challenge
  243. Pingback: Vidalista 20mg
  244. Pingback: smm panels
  245. Pingback: masturbator sleeve
  246. Pingback: bdsm toys
  247. Pingback: powerful vibrators
  248. Pingback: bondage set
  249. Pingback: first time anal
  250. Pingback: vibrating wand
  251. Pingback: buying a vibrator
  252. Pingback: choosing a dildo
  253. Pingback: clone a willy kit
  254. Pingback: education
  255. Pingback: viagra
  256. Pingback: viagra
  257. Pingback: viagra
  258. Pingback: viagra
  259. Pingback: viagra
  260. Pingback: viagra
  261. Pingback: viagra
  262. Pingback: viagra
  263. Pingback: sex
  264. Pingback: laptop app
  265. Pingback: VIAGRA
  266. Pingback: viagra for men
  267. Pingback: south beach diet
  268. Pingback: liposakshan
  269. Pingback: v bucks hack 2019
  270. Pingback: VIAGRA
  271. Pingback: FREE V BUCKS
  272. Pingback: VIAGRA
  273. Pingback: VIAGRA
  274. Pingback: free robux hack
  275. Pingback: anal plug trainer
  276. Pingback: nasonex
  277. Pingback: học makeup
  278. Pingback: vibrating anal toy
  279. Pingback: *!!XXI-How to
  280. Pingback: suction cup dildo
  281. Pingback: tarocard
  282. Pingback: malaysia escorts
  283. Pingback: vibrating panty
  284. Pingback: FUCK
  285. Pingback: fortnite v bucks
  286. Pingback: robux generator
  287. Pingback: v-bucks
  288. Pingback: phishtank warning
  289. Pingback: best p spot vibe
  290. Pingback: female vibrator
  291. Pingback: nude
  292. Pingback: Topmediamarkt.com
  293. Pingback: viagra
  294. Pingback: x-rated
  295. Pingback: types of sex toys
  296. Pingback: usps liteblue
  297. Pingback: food near me
  298. Pingback: streaming gratuit
  299. Pingback: legislation
  300. Pingback: dildo vibrator
  301. Pingback: best anal sex toys
  302. Pingback: 메이저놀이터
  303. Pingback: 먹튀사이트
  304. Pingback: dominos coupons
  305. Pingback: pizza coupons
  306. Pingback: free robux
  307. Pingback: SPAM
  308. Pingback: escort directory
  309. Pingback: legal
  310. Pingback: xxx
  311. Pingback: laws
  312. Pingback: 메이저놀이터
  313. Pingback: 카지노사이트
  314. Pingback: 황금성
  315. Pingback: cbd oil for sale
  316. Pingback: laweekly.com
  317. Pingback: male toy kit
  318. Pingback: bunny ear vibrator
  319. Pingback: Lease End Cleaners
  320. Pingback: porno
  321. Pingback: kinky
  322. Pingback: biiig stiiizy
  323. Pingback: TylöHelo
  324. Pingback: Film Streaming
  325. Pingback: SeventyOne
  326. Pingback: Threema Messenger
  327. Pingback: BLK-429
  328. Pingback: SSNI 620

Leave a Reply