mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
Core: Improve elementValue method
Do not rewrap several times. Call .val() only when required. Closes #1055
This commit is contained in:
committed by
Jörn Zaefferer
parent
03cd4c9306
commit
6c041edd21
@@ -558,13 +558,15 @@ $.extend($.validator, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
elementValue: function( element ) {
|
elementValue: function( element ) {
|
||||||
var type = $(element).attr("type"),
|
var val,
|
||||||
val = $(element).val();
|
$element = $(element),
|
||||||
|
type = $element.attr("type");
|
||||||
|
|
||||||
if ( type === "radio" || type === "checkbox" ) {
|
if ( type === "radio" || type === "checkbox" ) {
|
||||||
return $("input[name='" + $(element).attr("name") + "']:checked").val();
|
return $("input[name='" + $element.attr("name") + "']:checked").val();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val = $element.val();
|
||||||
if ( typeof val === "string" ) {
|
if ( typeof val === "string" ) {
|
||||||
return val.replace(/\r/g, "");
|
return val.replace(/\r/g, "");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user