Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with checking form fields 1

Status
Not open for further replies.

BigDoug

IS-IT--Management
Feb 20, 2002
49
US
I have a form field that is processed by CGI and I want to incorporate a check of the form field that makes sure that there is only these file extensions in the field along with a web address like so:

1. User inputs OR

2. CGI checks to make sure that only web addresses with mp3 or MP3 or WMA or wma are input. If you entered anything other than those four extensions in the we address of the field, the ERROR routine is invoked.

Is there a good place on the web to get some help on this? I have the majority of the code done, but I do not know how to get the final steps done. Below is my code so far:


OWA::error(&quot;You must use the extensions of .mp3, .MP3, .wma or .WMA in your URL tag!&quot;) if $form{'music_url'} =<HERE IS WHERE I AM STUMPED>;
 
[tt]... if $form{'music_url'} =~ /\.(mp3|wma)$/i;[/tt]
The regex matches a literal period \. and either mp3 or wma (mp3|wma) anchored to the end of the string $. The /i switch does it case insensitively, so it'll accept .wMa files, too.

For more details than you'd ever think you'd want to know:
----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Excellent! Exactly what I needed. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top