Hi,
I need a javascript RegExp for image file validation from a file upload
form.
I need to allow image files only (jpeg/jpg/gif/png)
can anybody help me please?
thanks,
Paul. 5 3223
wrote on 24 sep 2006 in comp.lang.javas cript:
I need a javascript RegExp for image file validation from a file upload
form.
need != want
I need to allow image files only (jpeg/jpg/gif/png)
Extention testing != file testing
can anybody help me please?
var isImageExtentio n = /.\.(jpe?g||gif| |png)$/i.test(t);
Not tested.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Evertjan. wrote:
var isImageExtentio n = /.\.(jpe?g||gif| |png)$/i.test(t);
....which allows ghost extension, too :)
Not tested.
Me neither, shame on us, coffee break?
Elegie wrote on 24 sep 2006 in comp.lang.javas cript:
Evertjan. wrote:
>var isImageExtentio n = /.\.(jpe?g||gif| |png)$/i.test(t);
...which allows ghost extension, too :)
Please explain.
>Not tested.
Me neither, shame on us, coffee break?
No coffee, why are you not tested?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Evertjan. wrote:
>>var isImageExtentio n = /.\.(jpe?g||gif| |png)$/i.test(t);
...which allows ghost extension, too :)
Please explain.
alert(/.\.(jpe?g||gif| |png)$/i.test("foo.")) ;
The syntax of regular expressions defines a single pipe as separator for
alternatives, doubling them results in your final production allowing no
extension at all.
>>Not tested.
Me neither, shame on us, coffee break?
No coffee, why are you not tested?
They weren't that friendly so I escaped :)
Cheers.
Elegie wrote on 24 sep 2006 in comp.lang.javas cript:
Evertjan. wrote:
>>>var isImageExtentio n = /.\.(jpe?g||gif| |png)$/i.test(t); ...which allows ghost extension, too :)
Please explain.
alert(/.\.(jpe?g||gif| |png)$/i.test("foo.")) ;
The syntax of regular expressions defines a single pipe as separator for
alternatives, doubling them results in your final production allowing no
extension at all.
That's why I didn't test ;-{
>>>Not tested. Me neither, shame on us, coffee break?
No coffee, why are you not tested?
They weren't that friendly so I escaped :)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: CSDunn |
last post by:
Hello,
I need to apply validation to two text boxes. One text box named
FirstNumber is required to contain only numbers, and be only three
digits long.
The other text box named SecondNumber needs to also require only
numbers, but allow for four digits.
I need to have a msg box appear after the user clicks a button named
'submit' if the validation on either text box has been violated.
|
by: J. J. Cale |
last post by:
Little astrology program has 2 text input boxes for birth dates. There are 3
selects for day month year that will supply output to whichever text input
had the focus last. If the user picks from the list boxes the relative text
input field is formatted d/m/y, the format that the cgi is expecting. The
user can also input directly to the text inputs and I would like to route
whatever the user inputs through a filter using regexes wherever...
|
by: phal |
last post by:
Hi all;
I code Perl for CGI, I using regular expression to check the validation
of user input, because the form is small and it run only from my own
computer, anyways if many people using my form, do you think it will be
slow due to Perl is run under server. How about using JavaSCript to
check validation for user input? Do you think it a bit faster?
|
by: Dag Sunde |
last post by:
My understanding of regular expressions is rudimentary,
at best.
I have this RegExp to to a very simple validation of an
email-address, but it turns out that it refuses to
accept mail-addresses with hypens in them.
Can anybody please help me adjust it so it will accept
addresses like dag-sunde@test-domain.net too?
|
by: Dmitry Korolyov |
last post by:
ASP.NET app using c# and framework version 1.1.4322.573 on a IIS 6.0 web server.
A single-line asp:textbox control and regexp validator attached to it.
^\d+$ expression does match an empty string (when you don't enter any values) - this is wrong
d+ expression does not match, for example "g24" string - this is also wrong
www.regexplib.com test validator works fine for both cases, i.e. it is reporting "not match" for the...
| |
by: Matt Kruse |
last post by:
Are there any current browsers that have Javascript support, but not RegExp
support?
For example, cell phone browsers, blackberrys, or other "minimal" browsers?
I know that someone using Netscape 3 would fall into this category, for
example, but that's not a realistic situation anymore.
And if such a condition exists, then how do you guys handle validation using
regular expressions, if the browser lacks them?
For example:
|
by: Christoph |
last post by:
I'm trying to set up client side validation for a textarea form element to
ensure that the data entered does not exceed 200 characters. I'm using the
following code but it doesn't seem to be working correctly:
if( this.value != '' ) {
if( !( RegExp( '^{0,200}$' ).test( this.value ))) {
alert( 'Information provided must not be more than 200 characters.' );
this.focus();
}
}
|
by: Milagro |
last post by:
Hello Everyone,
I'm trying to debug someone elses php code. I'm actually a Perl
programmer, with OO experience, but not in php.
The code is supposed to upload a photo from a form and save it both on
the file system and in a mySql database. 90% of the time it works just
fine. But for some reason, with some photos, it doesn't work. The
image never shows up on the filesystem and there is no entry in the
database. I feel it's a problem...
|
by: yatin |
last post by:
hi, friend. i have a problem in image validation plz check it.
i have to include a image validation in foam 1. but i sending a details through form2.
But when i include a image validation in foam1, then i can not change my image on
calling a function onchange="return valid1"
<my source code is here>
<?
session_start();
ob_start();
set_time_limit(0);
include("includes/vars.inc.php");
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |