/    Sign up×
Community /Pin to ProfileBookmark

Validate manual URL entry

I have a url where the last character or characters has to be a number after the last / in the url page. Everything works great where the last character/s is always a number after the final / in the URL:
[url]http://myserver:8080/mypage/2[/url]
or
[url]http://myserver:8080/mypage/4[/url]
or
[url]http://myserver:8080/mypage/12[/url]

Sometimes a user will manually enter the url in their Browser and put a non Integer at the end of the url where it should only be a Integer:
[url]http://myserver:8080/mypage/ab[/url]
or
[url]http://myserver:8080/mypage/4g[/url]

This gives an error message and I was hoping to create something in JavaScript to give a customized error page or redirect to a customized error page. The main thing is I dont want the Server side error message to show when someone puts in an invalid URL entry with non integer number after the last / in the url.

Please advise how I can handle this using JavaScript?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@holyhttpMay 07.2007 — To my knowledge if a request is made to the server then the response will abviously come from the server.

Therefore to avoid the server 404 error message, you can create you very own Error 404 by inserting thine line in your htaccess file:

ErrorDocument 404 http://yourdomain-name/error404.html

then you can create an html file named error404.html and put your custom error message.
×

Success!

Help @florida 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 5.21,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...