Two quick questions:
First, what's a nice online javascript reference? I'm very new to JS (ie: moving from fixing things to writing things) and I keep googling for things as I need them and up at a bunch of crappy w3schools type sites. Something similar to (god help me) the php reference perhaps.
Second, what are the rules regarding the match inside a switch statement?
I had this little snippet really confusing me for a bit. The typo is obvious, I was yanking/putting in vim and missed the "break":
The way this behaved is an input field named "email" ended up hitting both of those "case" statements and it had both classes added. I know I should have the "break;" at the end of each matching block, but I don't follow why the switch statement executed the "email-nobkg" match. Any clues? I was looking for more detailed info on what kind of matching one can do in the "case" block, but came up with very little. For all I know putting a match in double-quotes makes it a really loose match or something.
First, what's a nice online javascript reference? I'm very new to JS (ie: moving from fixing things to writing things) and I keep googling for things as I need them and up at a bunch of crappy w3schools type sites. Something similar to (god help me) the php reference perhaps.
Second, what are the rules regarding the match inside a switch statement?
I had this little snippet really confusing me for a bit. The typo is obvious, I was yanking/putting in vim and missed the "break":
Code:
switch(fieldName) {
case "email":
if(!emailReg.test(inputVal) || inputVal == '' ){
$(this).addClass('errorbkg-email');
$parentTag.append('<span class="error" id="error" style=
"display:none;">email</span>');
// there should be a break; here
}
case "email-nobkg":
if(!emailReg.test(inputVal) || inputVal == '' ){
$(this).addClass('errorbkg');
$parentTag.append('<span class="error" id="error" style=
"display:none;">email nobkg</span>');
}
break;
[and so on, a few more matches]
The way this behaved is an input field named "email" ended up hitting both of those "case" statements and it had both classes added. I know I should have the "break;" at the end of each matching block, but I don't follow why the switch statement executed the "email-nobkg" match. Any clues? I was looking for more detailed info on what kind of matching one can do in the "case" block, but came up with very little. For all I know putting a match in double-quotes makes it a really loose match or something.