JQuery plugin hints and problem with $ _POST

I am using remy sharp hint plugin .

<input type="text" title="hint" name="names" class="input" />

But when I submit the form without filling in the fields, the input still has

  $_POST['names'] = 'hint';

How can I prevent this problem?

Thanks in advance.

EDIT: jQuery code:

$(".input").hint();

$(".lSubmit").click(function(e){
   e.preventDefault();
   $.post('form.php',decodeURIComponent($("#forms").serialize()) , function(data) {
   $('.result').html(data);
     });
 });
+5
source share
2 answers

The plugin removes the tooltip when the form into which the input is entered is submitted, unfortunately you do not submit the form, but submit it through $.post.

The easiest way is probably to check the value (s) of the input (s) just before it is sent against its header, and clear it if they are the same:

$(".lSubmit").click(function(e){

   // clear inputs that still have the hint as value
   $('.input').each(function() {
      if($(this).val() == $(this).attr('title')) {
         $(this).val("");
      }
   });

   e.preventDefault();
   $.post('form.php',decodeURIComponent($("#forms").serialize()) , function(data) {
   $('.result').html(data);
     });
 });
+3
source

You can not.

Just add the if code to the code:

if($_POST['names'] == 'hint' ) {
   //DONT USE IT!!
}
0
source

All Articles