Checking if forms contain a certain string

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Checking if forms contain a certain string
pnclthnmstsh
CZ Active Member
pnclthnmstsh has been a member for over 19 year's 19 Year Member
usa.gif nevada.gif
Age: 53
Gender: Male
Website:
Status: Offline
Joined: Sep 17, 2004
0.04 posts per day
Posts: 267
Points: 13,641
   
I'm trying to verify that a form field contains gif, jpg or png i and what i've got does check, however it verifies that the field ONLY contains one of those. If anything else...like the rest of the URL to the image is in the field it returns the alert.

function imagecheck(){
var string1=document.validation.image.value
if (string1.indexOf("gif")==0 || string1.indexOf("jpg")==0 || string1.indexOf("png")==0){
}
else{
alert("Only gif, jpg and png images are allowed!")
document.validation.image.focus()
}
}


Thanks for any suggestions on how to allow other chars in that field too icon_smile.gif



_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#2   re: Checking if forms contain a certain string
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 42
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
I keep trying to grasp what your saying, but could we get an example?



Back to top Reply with quote
#3   
pnclthnmstsh
CZ Active Member
pnclthnmstsh has been a member for over 19 year's 19 Year Member
usa.gif nevada.gif
Age: 53
Gender: Male
Website:
Status: Offline
Joined: Sep 17, 2004
0.04 posts per day
Posts: 267
Points: 13,641
   
In the emailer for the Link Exchange I made that you saw in another post, there's a field where you input the link to your image. I am trying to make a javascript function that will check that field for the string gif, jpg or png to help make sure they put an image in. I am also hoping to come up with one that checks the structure of a URL.
For now I could start em off on the right track by giving those fields a value of [ Register or login to view links on this board. ] but it would be nice to mistake proof those fields.




_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum