• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Validating File Name

There are many things that can be done with regular expressions, but one of the most useful is validating entry fields in forms on your Web pages. Script 7.2 expects the user to enter a valid URL of an image, and the regular expression helps to make sure that the user does as he should (specifically, that there has to be a .gif or .jpg suffix to denote an image file). Figure 7.3 shows the appearance of the page when it's first loaded, Figure 7.4 when an invalid entry was accidentally entered, and Figure 7.5 shows the result when the image name was typed correctly.

Figure 7.3. Here's the page as it appears when it's first loaded, with no image showing.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint