CS 6314.001/002 – Practice Work 2

$35.00

Download Details:

  • Name: pw-2-lv5xyu.zip
  • Type: zip
  • Size: 15.78 KB

Category:

Description

5/5 - (1 vote)

Your html page will include three textboxes for username, password and phone number, one “Validate” button and one empty paragraph at the end of the page. When user clicks on the button, you will validate the user input by using Javascript.

Validation rules: co

  1. All fields are mandatory.
  2. Username and password should be at least 6 characters.
  3. Phone number should include only numbers.

 

 

If user input is valid, change the text for paragraph and show the success message. The text color for the success message will be green.

 

If it is not valid, change the text for the paragraph and show all errors. The text color for the error messages will be red.

 

Write unobtrusive script code for attaching event handlers to the events and also for changing style properties of elements (css properties should be defined as css classes and you should change the class of the paragraph from Javascript).

 

 

Note: Check rules 2 and 3 only if all fields are given. Otherwise show error message “All fields are mandatory”.

 

 

 

  1. Do not use “required” attribute on HTML
  2. Change the CSS class in JS and not CSS property (eg: color)
  3. Use click event handler in JS
  4. *Try to use regular expressions for validation

 

 

改进:

validate最开始reset一下颜色

整合一下变颜色的,写成一个函数

变成onclick()