Form validation function (true or false) - Javascript

I need a form validation function that returns true or false if it is validate. For example, given an HTML document with the following content within the <body> tag: This function should return true, while given the following content:

<form>       <input type="radio" id="type_person" name="type" value="person" checked/>       <input type="radio" id="type_company" name="type" value="company"/>       <input type="text" id="first_name" name="first_name" value="John"/>       <input type="text" id="last_name" name="last_name" value="Doe"/>       <input type="text" id="email" name="email" value="[email protected]"/>       <input type="text" id="company_name" name="company_name" value=""/>       <input type="text" id="phone" name="phone" value="234-567-890"/>     </form> 

your function should return false (the phone number is not correct):

<form>   <input type="radio" id="type_person" name="type" value="person"/>   <input type="radio" id="type_company" name="type" value="company" checked/>   <input type="text" id="first_name" name="first_name" value="John"/>   <input type="text" id="last_name" name="last_name" value="Doe"/>   <input type="text" id="email" name="email" value="[email protected]"/>   <input type="text" id="company_name" name="company_name" value="ACME"/>   <input type="text" id="phone" name="phone" value="12-3"/> </form> 

Empty function:

function solution() {  } 

Replay

Category: javascript Time: 2016-07-31 Views: 73

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.143 (s). 13 q(s)