Is it possible to replace a select list (that开发者_StackOverflow 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?
$.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"
);
http://jsfiddle.net/X8rS6/
u can do this like below
$("#selectlist option:first").html("you should select value");
if that option without value is ur first one
精彩评论