Tải bản đầy đủ - 0 (trang)
Chapter 15. Dynamic HTML: Style Sheets, the DOM, and JavaScript

Chapter 15. Dynamic HTML: Style Sheets, the DOM, and JavaScript

Tải bản đầy đủ - 0trang

Chapter12.HandlingEvents



Chapter14.Cookies



AppendixC.CGIandPerl:TheHyper

DynamicDuo

SectionC.1.WhatIsCGI?

SectionC.2.InternetCommunicationBetweenClientand

Server

SectionC.3.CreatingaWebPagewithHTML

SectionC.4.HowHTMLandCGIWorkTogether

SectionC.5.LogFiles

SectionC.6.WheretoFindCGIApplications

SectionC.7.GettingInformationIntoandOutoftheCGI

Script

SectionC.8.ProcessingFormswithCGI

SectionC.9.TheCGI.pmModule

EXERCISEC.1

EXERCISEC.2



Chapter13.RegularExpressionsand

PatternMatching



13.4FormValidationwithRegularExpressions

WhenyoufilloutaformontheWeb,youaretypicallyaskedfor

yourname,phone,address(apop-upmenuofallthestatesis

usuallyprovided),andthenallsortsofcreditcardstuff.

Sometimesittakesfourorfivetriestogetitrightbecauseyou

didn'tcompletetheformexactlythewayyouwereasked.A

messagewillappearandyouwon'tbeallowedtosubmitthe

formuntilyougetitright.BehindthescenesaJavaScript

programisvalidatingtheform.



13.4.1CheckingforEmptyFields

There'saformwaitingtobefilledout.Someofthefieldsare

optional,andsomearemandatory.Thequestionis,didtheuser

fillinthemandatoryfields?Ifhedidn't,theformcan'tbe

processedproperly.Checkingforemptyornullfieldsisoneof

thefirstthingsyoumaywanttocheck.



Example13.36







CheckingforEmptyFields



1functionvalidate_text(form1){

2if(form1.user_name.value==""||form1.user_name.valu

null){

alert("Youmustenteryourname.");

returnfalse;

}

3if(form1.user_phone.value==""||form1.user_phone.va



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 15. Dynamic HTML: Style Sheets, the DOM, and JavaScript

Tải bản đầy đủ ngay(0 tr)

×