eg-259:lecture7
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
eg-259:lecture7 [2012/02/22 12:06] – [HTML5 Version of the Phone Number Validator] eechris | eg-259:lecture7 [2013/02/12 20:10] – [Form Validation] eechris | ||
---|---|---|---|
Line 9: | Line 9: | ||
====== Text Processing with Regular Expressions ====== | ====== Text Processing with Regular Expressions ====== | ||
- | **Contact Hour 10**: To be discussed on Tuesday | + | **Contact Hour 10**: To be discussed on Tuesday |
**Lecturer**: | **Lecturer**: | ||
Line 267: | Line 267: | ||
* avoids a trip to server that would result in an error page | * avoids a trip to server that would result in an error page | ||
* error handling is kept local | * error handling is kept local | ||
- | * usually triggered by // | + | * usually triggered by // |
* error message generated locally by writing into document object. | * error message generated locally by writing into document object. | ||
- | * This example defines a function that could be used in a registration page to check that a phone number is valid (using US conventions!) HTML5 Markup: [[/ | + | * This example defines a function that could be used in a registration page to check that a phone number is valid (using US conventions!) HTML5 Markup: [[http:// |
---- | ---- | ||
Line 287: | Line 287: | ||
</ | </ | ||
< | < | ||
+ | < | ||
: | : | ||
- | <form id=" | + | <form id=" |
+ | onsubmit=" | ||
<label for=" | <label for=" | ||
- | <input id=" | + | <input id=" |
- | | + | title=" |
- | <input type=" | + | <input type=" |
</ | </ | ||
| | ||
- | <!-- Best practice guidelines suggest that you load scripts | + | <!-- Best practice guidelines suggest that you load scripts |
<script src=" | <script src=" | ||
</ | </ | ||
Line 366: | Line 368: | ||
===== HTML5 Version of the Phone Number Validator ===== | ===== HTML5 Version of the Phone Number Validator ===== | ||
- | * [[/ | + | * [[http:// |
---- | ---- | ||
Line 372: | Line 374: | ||
<code html> | <code html> | ||
< | < | ||
- | < | + | < |
- | Uses the new HTML5 pattern attribute | + | A function tst_phone_num is defined and tested. |
- | to validate | + | This function checks the validity of phone |
- | --> | + | number |
- | <html lang=" | + | --> |
+ | < | ||
< | < | ||
- | <meta charset=" | + | <meta charset=" |
+ | <meta http-equiv=" | ||
< | < | ||
+ | <meta name=" | ||
+ | |||
+ | <link rel=" | ||
+ | <link rel=" | ||
+ | <link rel=" | ||
+ | |||
+ | <script src=" | ||
</ | </ | ||
< | < | ||
- | < | + | |
- | <p>An example of the use of Regular Expressions for form validation. View source to see the code.</ | + | |
- | < | + | <p>An example of the use of Regular Expressions for form validation. View source to see the code.</ |
- | < | + | < |
- | </ | + | < |
- | < | + | </ |
- | this can be used instead of JavaScript for form validation.</ | + | < |
- | <p>In production, you would normally need to provide a JavaScript fallback for browsers that don't yet support the < | + | this can be used instead of JavaScript for form validation.</ |
- | <!-- No need for onsubmit validator now --> | + | <p>In production, you would normally need to provide a JavaScript fallback for browsers that don't yet support the < |
- | <form id=" | + | <!-- No need for onsubmit validator now --> |
- | <label for=" | + | <form id=" |
- | <input id=" | + | <label for=" |
- | | + | <input id=" |
- | | + | |
- | <input type=" | + | |
- | </ | + | <input type=" |
- | | + | </ |
+ | | ||
+ | |||
+ | <script src="// | ||
+ | < | ||
+ | |||
+ | <script src=" | ||
+ | <script src=" | ||
<!-- Look no scripts! --> | <!-- Look no scripts! --> | ||
</ | </ |
eg-259/lecture7.txt · Last modified: 2013/02/19 12:29 by eechris