Text field with alphabet restriction

i want textfield .. like nobody can enter number in it. if somebody try to enter number show message...

i don't want in javascript... just in html
deepakabcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Not doable without scripting. HTML is just markup. The scripting is what makes the page "interactive". Basically the page needs to "react" to the user input. Without scripting, this is a dead end.
0
boro_bobCommented:
Hielo is correct. There is no way of doing this without using javascript and a regular expression.

Have a look at this web page for more information on how to do it.

http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
0
simply_dhavalCommented:
not doable with simple html  as they said alredy

may be you should explore the html DTDs more, to check it out

may be you can try  xhtml which have document design in xml but then to represnt the content you will have to use xslt
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

deepakabcAuthor Commented:
i tried with javascript but still not working can u give me more code to help in validation
0
hieloCommented:
Take a look at this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript"><!--
function validate(obj)
{
 
	if( false === /^[A-Z]+$/i.test( String(obj.value) ) )
	{
		alert("Please supply only alphabetic characters.");
		//clear the invalid value
		obj.value="";
	}
}
//--></script>
</head>
<body>
<form name="theForm">
<input type="text" name="sample" value="" onblur="validate(this)"/>
</form
</body>
</html>

Open in new window

0
deepakabcAuthor Commented:
This code is not working sorry
0
hieloCommented:
Yes, it's working. It gives the message as soon as the user clicks or tabs out of the text field. The example below gets rid of the non-alphabetic characters AND notifies the user as well.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript"><!--
function validate(obj)
{
 
	if( false === /^[A-Z]+$/i.test( String(obj.value) ) )
	{
		alert("Only alphabetic characters are allowed.");
		//clear the invalid value
		obj.value=obj.value.replace(/[^A-Z]/ig,"");
	}
}
//--></script>
</head>
<body>
<form name="theForm">
<input type="text" name="sample" value="" onblur="validate(this)"/>
</form
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
simply_dhavalCommented:
have you enabled java script in your browser ?

and you may have to twist the code a bit depening upon your browser specifically there is noticeable difference when you test codes on mozilla and ie
0
deepakabcAuthor Commented:
i tried in both internet and firefox but still code is not working...

all i do i copy and paste the code in the html file and try to run it.. but it took character without warning message
0
simply_dhavalCommented:
can you just show me screen shot of what you get in browser ?
0
deepakabcAuthor Commented:
check it out
screenshot.jpg
0
deepakabcAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.