Is it possible to replace a select list (that is required) default value with an error message if it isn't changed? EX if you click submit without selecting a value, replacing the default "Please Select" that has no option value with a "Please select an option" message? If so, how?
+1
A:
$.validator.addMethod(
"SelectTechnology",
function(value, element) {
if (value == '0'){
$('#singleTech option[value="0"]').text("You forgot to select one!");
return false;
}
else
return true;
},
"Please Select a Technology"
);
RememberME
2010-09-30 14:52:03
@RememberME - thats it! thx, i think this will fix the situation i found myself in yesterday. Ill probably just add a red outline to the box on error and not use a message, that way it wont have the issue of not removing it..hopefully.
Dirty Bird Design
2010-09-30 14:58:16
That will still only work on the change event. Which isn't being triggered in Firefox on Select. So, you wouldn't be able to remove the red box there. But, you would lose the message once something was selected.
RememberME
2010-09-30 15:55:06
can you add a class on change? like $("singleTech").change().css('border','none'); ?
Dirty Bird Design
2010-09-30 16:06:53
The problem is that for your link, the change event doesn't seem to fire when a selection is made.
RememberME
2010-09-30 16:20:25
@RememberME so i guess the best is to just go with no message below the box, insert the message via .text inside the box and don't style it any different. so strange.
Dirty Bird Design
2010-09-30 16:37:00
A:
u can do this like below
$("#selectlist option:first").html("you should select value");
if that option without value is ur first one
Muhammad Adeel Zahid
2010-09-30 14:52:25