In the jquery below should there be a closing paretheses “)” before the “dot” in:
“.test($ …”?
(/^\s*$/.test($(this).val()))
$(document).ready(function () {
$('#userlogin').css('color', '#cccccc').val('LOGINNAME');
$('#userlogin').blur(function () {
if (/^\s*$/.test($(this).val())) {
$(this).val('LOGINNAME');
$(this).css('color', '#cccccc');
$(this).valid();
}
}).focus(function () {
if ($(this).val() === 'LOGINNAME') {
$(this).val('');
$(this).css('color', '#000000');
}
});
If not, why not? That code looks a little weird to me.
The code is correct:
However, the value could be cached:
var val = $(this).val();.Then the line might be less confusing to you:
/yourregex/.test(val)