The toLowerCase () method is used to convert a string to lowercase.
Grammar
Stringobject.tolowercase () return value
A new string in which all uppercase characters of stringobject are converted to lowercase characters
The LastIndexOf () method returns the last occurrence of a specified string value, which is searched forward at the specified position in a string.
Grammar
Stringobject.lastindexof (searchvalue,fromindex) parameter description
Searchvalue required. A string value that requires retrieval.
Fromindex an optional integer parameter. Specify where to start retrieving in the string. Its legal value is 0 to stringobject.length-1. If this argument is omitted, the retrieval begins at the last character of the string.
return value
If Searchvalue exists before the fromindex position in the Stringobject, the position of the last searchvalue that appears is returned.
Below see a use toLowerCase LastIndexOf limit only can upload picture code
function Checkphoto (fnupload)
{
var filename = fnupload.value;
alert (filename);
var mime = filename.tolowercase (). substr (Filename.lastindexof ("."));
if (mime!= ". jpg")
{
Alert ("Please select JPG photo upload");
fnupload.outerhtml=fnupload.outerhtml;
}
}