week 3€¦  · web viewsyntactically, the core javascript language resembles c, c++ and java,...

18
Week 3 Aim VALIDATION: Write JavaScript to validate the following fields of the above registration page. 1. Name (Name should contains alphabets and the length should not be less than 6 characters). 2. Password (Password should not be less than 6 characters length). 3. E-mail id (should not contain any invalid and must follow the standard pattern [email protected] ) 4. Phone number (Phone number should contain 10 digits only). Note : You can also validate the login page with these parameters. Description JavaScript is a lightweight interpreted programming language with rudimentary object-oriented capabilities. Syntactically, the core JavaScript language resembles C, C++ and Java, with programming constructs such as the if statement, the while loop, and the && operator. The similarity ends with this syntactic resemblance, however. JavaScript is an untyped language, which means that variables do not have to have a type specified. The <SCRIPT> and </SCRIPT> tags are used to embed JavaScript code within an HTML file. Source Code Registration.html

Upload: vuonglien

Post on 18-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Week 3Aim

VALIDATION:

Write JavaScript to validate the following fields of the above registration page.

1. Name (Name should contains alphabets and the length should not be less than 6 characters).

2. Password (Password should not be less than 6 characters length).

3. E-mail id (should not contain any invalid and must follow the standard pattern [email protected])

4. Phone number (Phone number should contain 10 digits only).

Note : You can also validate the login page with these parameters.

Description

JavaScript is a lightweight interpreted programming language with rudimentary object-oriented capabilities. Syntactically, the core JavaScript language resembles C, C++ and Java, with programming constructs such as the if statement, the while loop, and the && operator. The similarity ends with this syntactic resemblance, however. JavaScript is an untyped language, which means that variables do not have to have a type specified.

The and tags are used to embed JavaScript code within an HTML file.

Source Code

Registration.html

Registration Page

var errorFound=false;

function containAlphabets(checkString){//To validate Name Field charactersvar result=true;var regExp=/^[A-Z a-z]$/;

if(checkString!=null && checkString!=""){for(var i=0;i=6){return true;}else{return false;}}function validatePasswordLength(password){//To validate Password Field lengthif(password.length>=6){return true;}else{return false;}}

function validateEmail(email){var x=document.regform.email.value;var atpos=x.indexOf("@");var dotpos=x.lastIndexOf(".");if (atpos