I'm working with the following HTML
Level 1: <input type="text" name="benefit_std_level1" maxlength="5" value="0.0" onblur="noSpaceTest();float_5_2_percent(this);" style="width:40px;" class="input nospace">%<br />
Level 2: <input type="text" name="benefit_std_level2" maxlength="5" value="0.0" onblur="noSpaceTest();float_5_2_percent(this);" style="width:40px;" class="input40 nospace">%<br />
Level 3: <input type="text" name="benefit_std_level3" maxlength="5" value="0.0" onblur="noSpaceTest();float_5_2_percent(this);" style="width:40px;" class="input nospace">%<br />
There is an error occurring in the database if a user inputs a space into any of the three "Level" fields. I'm therefore employing the following script to check for a space and then change the value back to the default '0.0'.
jQuery:
function noSpaceTest(){
$('.nospace').each(function(){
if ($('.nospace').val() == ' '){
$('.nospace').val('0.0');
}
});
}
Originally, in the site I'm developing, this did work, but only for the first field (onBlur would check and find the space and replace it with 0.0) However, now I can't get it to work in JSFiddle (see link below)
I'm afraid I'm missing something obvious, but I'm not getting any closer to a resolution. Does anyone have any insight they can offer?