Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,812 members, 7,810,115 topics. Date: Friday, 26 April 2024 at 09:01 PM |
Nairaland Forum / Science/Technology / Webmasters / Javascript Validation (572 Views)
Comment Box Validation (urgent) / Form Validation Tutorial Using Javascript, Php, Ajax / Form Validation Tutorial Using Javascript, Php And Ajax! (2) (3) (4)
Javascript Validation by akereconfi: 2:03am On Nov 18, 2014 |
Hello, please I need a helping hand on JavaScript validation on checking for numbers in a text field. Have tried w3school but got only validation for email Thanks for your contribution |
Re: Javascript Validation by Craigston: 3:18am On Nov 18, 2014 |
akereconfi:Uh, what's your code so far? |
Re: Javascript Validation by akereconfi: 3:34am On Nov 18, 2014 |
Craigston: <script> function validateForm() { var x = document.forms["myForm"]["fname"].value; if (x==null || x=="" { alert("First name must be filled out" return false; } } </script> </head> <body> <form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post"> First name: <input type="text" name="fname"> <input type="submit" value="Submit"> </form> </body> |
Re: Javascript Validation by Craigston: 3:57am On Nov 18, 2014 |
akereconfi:You said you want to check for number in the string. What would you like to do if a number is found? You can use 'parseInt()' or 'parseFloat()' here. if (parseInt(x) != "" {do something}; |
Re: Javascript Validation by Craigston: 3:58am On Nov 18, 2014 |
akereconfi:You said you want to check for number in the string. What would you like to do if a number is found? You can use 'parseInt()' or 'parseFloat()' here. if (parseInt(x) != "" ) {do something}; |
(1) (Reply)
URGENTLY: It/web Developer Needed Must Have Extensive Prestashop Experience / How To Start Free Video Call With Mozilla Firefox Browser / Dreamhost $97 Discount Promo Code 2015
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17 |