Here's the deal.
Jack wanted to find a space character in an <input> but using CSS3 selectors.Well, if you want to create an actual CSS3 rule in your stylesheet, then input[value*=' ']{..} will work, but only for values in the actual attribute (in the source code) and not the value as modified inside the browser..
For eg:
<form>
<input type="text" value="no-space-here" /><br/>
<input type="text" value="" /><br/>
<input type="text" value="space here" /><br/>
<input type="text" value="" /><br/>
<input type="submit" value="submit"> type a space and press Submit
</form>
CSS
input[value*=' ']{
background-color:#fff5f5;
}
Run the code here and see for yourself. http://jsfiddle.net/8BdUV/
A good solution is to use jQuery here
return ($(':input[value*=" "]').addClass('warning').length > 0) ? false : true;
});
CSS
.warning{
background-color:#fff5f5;
}
Now run the solution http://jsfiddle.net/PHja9/
Bingo!
0 comments:
Post a Comment