change font property on keypress

Posted on 2013-09-27
Medium Priority
Last Modified: 2013-10-03
I have a textbox which by default/design I set to italic and font color  as gray.
I would like to set it to normal and black when I enter data in the textbox.
I could not find a  keypress event.
Also Id  like only characters and no numbers are allowed in it.
Question by:zachvaldez

Author Comment

ID: 39529661
im looking the way the searchbutton works on this page.. look up to the right please.
LVL 53

Expert Comment

ID: 39530103
You are not getting any responses, because you have not posted any code or a link.

LVL 41

Expert Comment

ID: 39530113
Asp.net textbox doesn't have a built in key events. You will need jquery for that.
LVL 15

Accepted Solution

Insoftservice earned 1240 total points
ID: 39534261
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <title>Love to marry an free matrimonial website</title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
    <script type="text/javascript">

  function PressEnter(myfield,e,callback)
       var keycode;
       if (window.event) keycode = window.event.keyCode;
       else if (e) keycode = e.which;
       else return true;

       if (keycode == 13)
         if (callback) {
         return false;
         return true;

function colorChange()
 var field =   $('#testfield');
 field.css({ "color": "black", "font-weight": "normal" });

<form name='frm'>
<input type=text" id="testfield" onkeypress="return PressEnter(this,event,'colorChange()');" style="color:red;font-weight:bold"  >

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question