I'm trying to implement an image preview. It works fine until i came to a problem where i need to prevent the input file
to not change.
When trying to change to image its fine. After changing to image try to change the input file into a txt
file. its alerting the correct error, but the input file is also changed.
$('body').on('change','.input-preview',function(e){
var ito = $(this);
var img = ito[0].files;
var errs = [];
for(x=0;x<img.length;x++){
if(img[x].type!=='image/jpeg' && img[x].type!=='image/gif' && img[x].type!=='image/png'){
errs.push('Not image.');
break;
}
if(img[x].size>(1024000 * 5)){
errs.push('File is too big.');
break;
}
}
if(errs.length){
e.preventDefault();
alert(errs[0]);
return false;
}else{
previewIt(this, $('.preview-profile'));
}
});
The change
event is not cancelable. See the document on MDN.
This is my data with 5 arrays. What I wish to achieve is to combine id and name and the new array should have 5 different playname values. It can be in either an array or new key like playername1. [ ...
This is my data with 5 arrays. What I wish to achieve is to combine id and name and the new array should have 5 different playname values. It can be in either an array or new key like playername1. [ ...
I have an fuctions in JS like below. manager.addDocument('en', 'bye bye take care', 'greetings.bye'); manager.addDocument('en', 'okay see you later', 'greetings.bye'); manager.addDocument('en', ...
I have an fuctions in JS like below. manager.addDocument('en', 'bye bye take care', 'greetings.bye'); manager.addDocument('en', 'okay see you later', 'greetings.bye'); manager.addDocument('en', ...
I would like to extract numbers from a string such as There are 1,000 people in those 3 towns. and get an array like ["1,000", "3"]. I got the following number matching Regex from Justin in this ...
I would like to extract numbers from a string such as There are 1,000 people in those 3 towns. and get an array like ["1,000", "3"]. I got the following number matching Regex from Justin in this ...
So I have an array of objects that I receive like this: [ { accountName: { type: 'link', value: { value: '1234567890123456789', to: '/q?Id=1237896540789654', },...
So I have an array of objects that I receive like this: [ { accountName: { type: 'link', value: { value: '1234567890123456789', to: '/q?Id=1237896540789654', },...