tags:

views:

136

answers:

4

Hello guys,

I have actually this input field :

<input type="text" name="author" id="author" value="name* <?php echo $comment_author; ?>" size="22" tabindex="1" />

I'm using an asterisk inside 'value' in order to indicate it's a required field, because the designer needs it like that. But alas, the asterisk is not showing.

Do you know how to fix it ?

Many thanks.

+1  A: 

That should work just fine. There is nothing wrong with having an asterisk (*) within an attribute value in HTML. Can you show us the generated HTML (after PHP has run on the file)?

Sean Bright
Let me mark it as the correct answer. It was a 'clear values' script which was needing I refreshed the page :/ Sorry for don't check it before, I'll post it below.
Peanuts
+1  A: 

Try using the HTML encoded asterisk instead...

<input type="text" name="author" id="author" value="name&#42; <?php echo $comment_author; ?>" size="22" tabindex="1" />
Al
A: 

That's an annoying UI design! Put the asterisk in a Label next to the input box, not in it!

<label for="author">Name*</label>
<input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
Dan Diplo
Or maybe as a class on the input tag, identifiable to the user with CSS and accessible programmatically.
Al
A: 

Hi guys, sorry for the panic created (if any).

Here's the script that was avoiding a proper refresh. The old values (without the asterisk) were like sticky for some time, now it seems to be OK.

swapValues = [];
$("input").each(function(i){
    swapValues[i] = $(this).val();
    $(this).focus(function(){
        if ($(this).val() == swapValues[i]) {
            $(this).val("");
        }
    }).blur(function(){
        if ($.trim($(this).val()) == "") {
            $(this).val(swapValues[i]);
        }
    });
});

Thanks for all the inputs

Peanuts