CS 6314.001/002 – Practice Work 2

$40.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (5 votes)

Your html page will includethree textboxes for username, password and phone number, one “Validate” button and one empty paragraph at the end of the page. Whenuser 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 paragraphand 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 andshow 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()