File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes need a regular expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "need a regular expression" Watch "need a regular expression" New topic

need a regular expression

srivijay varma

Joined: Nov 15, 2006
Posts: 5

I need a regular expression which will alert me when it finds these characters in string we provide "'/#\.

For example : A sample code #"vijay" (at # and " it should give me alert).
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

What have you tried? What errors are you seeing?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
dharmendra Rathor

Joined: Mar 20, 2007
Posts: 17
May be this will help you
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<TITLE> New Document </TITLE>
<script type="text/JavaScript">
function checkString() {
var checkRE = '[\#\"\\\/\']' ;
var inputString = document.forms[0].phone.value
if(inputString.match(checkRE)) {
alert( "String contain special char " );
Enter string
<input type="text" name="phone" onKey Up="checkString()">
[ May 03, 2007: Message edited by: pragmatic dsr ]
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

"pragmatic dsr",

Please re-read the following quote from David's post:

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Pay particular attention to the phrase "Fictitious names are not allowed".

Adherance to these rules is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.

Failure to comply will result in the removal of your account.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: need a regular expression
It's not a secret anymore!