/    Sign up×
Community /Pin to ProfileBookmark

var re = /[jpg|jpeg]$/

jpeg or jpg must be selected by the visitors.
When I select [color=red]aaa.zip[/color], it displays [color=red]“jpeg or jpg “[/color]. What can I do? Thanks…

[code]
<script type=”text/javascript”>
function kontrol(){
var el = document.getElementById(‘inputfile’);
var re = /[jpg|jpeg]$/
if(re.test(el.value) ) { alert(“jpeg or jpg “); }
if(!re.test(el.value) ) { alert(“not jpeg and jpg “); }
}
</script>
</head>
<body>
<form action=”giris.php”>
<input type=”file” id=”inputfile” name=”ad” onkeypress=”return false;” onchange=”kontrol()”>
</form>
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@jsakalosJun 12.2007 — Try re=/(jpg|jpeg)$/;

And:

[code=php]

"test.zip".match(re);
"test.jpg".match(re);
"test.jpeg".match(re);

// or

re.test("test.zip");

[/code]
Copy linkTweet thisAlerts:
@samanyoluauthorJun 12.2007 — jsakalos


Your code is doing it.

or

var re=/.jp(e?)g$/
×

Success!

Help @samanyolu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...