SoFunction
Updated on 2025-02-28

jquery registration text box to get focus clear and lose focus assignment

In our development process, especially when registering a user, there will be an effect, which is to get the focus clear prompt in the text box. If the user does not enter information, we will lose the focus assignment on our prompt.

<html>
<head>
<meta http-equiv="content-type"content="text/html; charset=UTF-8"/>
<script src="http://127.0.0.1/"></script>
<script>
$(function(){
 $("#account").focus(function(){
  var account_value=$(this).val();
  if(account_value=="Please enter your account"){
  $(this).val("");
  }
 });
 $("#account").blur(function(){
  var account_value=$(this).val();
  if(account_value==""){
  $(this).val("Please enter your account");
  }
 });
});
</script>
</head>   
<body>

account:<input  type="text" value="Please enter your account" />

</body>
</html>

The above jquery registration text box to get the focus clear and lose focus assignment is the simple example of the editor sharing with you. I hope you can give you a reference and I hope you can support me more.