Advertisement
Guest User

JS

a guest
Dec 3rd, 2011
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function checkArtistDetails(form){
  2.  
  3.   var valid = true; //boolean
  4.   var fileName = form.filePictureFileName.value.toLowerCase();  //Sets chosen filename to LowerCase.
  5.  
  6.  //Checks if txtArtist is empty
  7.  if(form.txtArtist.value == "")
  8.  {
  9.     window.alert( "Please enter the artists name.");
  10.     form.txtArtist.focus();
  11.     valid = false ;
  12.   }
  13.  
  14.    //Checks if a file is choosen
  15.   if(fileName == "")
  16.   {
  17.     window.alert("Please choose a picture.");
  18.     form.filePictureFileName.focus();
  19.     valid = false;
  20.   }
  21.  
  22. /*
  23. #############################
  24. HERE'S THE PROBLEM.
  25. #############################
  26. */
  27.      //Checks if image-extension is correct
  28.   if(fileName.lastIndexOf(".jpg") == -1 || fileName.lastIndexOf(".png") == -1)
  29.   {
  30.      window.alert("Only '.jpg' and '.png' file types are allowed.");
  31.      valid = false;
  32.   }
  33.  
  34.   else{
  35.   return valid;}
  36. }
  37.  
  38. //resets ArtistName-field
  39. function resetArtistName(form){
  40. form.txtArtist.value="";
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement