slitaz-pizza rev 67

function.js: Remove special characters in flavor name
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Thu Nov 01 01:23:13 2012 +0100 (2012-11-01)
parents f2dd2dcde9e2
children f4ff182be550
files web/lib/functions.js
line diff
     1.1 --- a/web/lib/functions.js	Tue Oct 30 13:50:10 2012 +0100
     1.2 +++ b/web/lib/functions.js	Thu Nov 01 01:23:13 2012 +0100
     1.3 @@ -8,7 +8,17 @@
     1.4          alert("Please enter SliTaz pizza flavor name");
     1.5          document.forms["pizza"]["flavor"].focus();
     1.6          return false;
     1.7 -    }
     1.8 +    } else {
     1.9 +		var str = "!@#$%^&*()+=[]\\\';,./{}|\":<>?";
    1.10 +		for (var i = 0; i < document.forms["pizza"]["flavor"].value.length; i++) {
    1.11 +		  	if (str.indexOf(document.forms["pizza"]["flavor"].value.charAt(i)) != -1)
    1.12 +		  	{
    1.13 +			  	alert ("Invalid Flavor name.\n Please remove speciial characters.");
    1.14 +			  	document.forms["pizza"]["desc"].focus();
    1.15 +			  	return false;
    1.16 +		  	}
    1.17 +		}
    1.18 +	}
    1.19      if(document.forms["pizza"]["desc"].value == "")
    1.20      {
    1.21          alert("Please fill in the flavor description");