Encrypting user credentials in JS is probably even worse than parsing HTML with regular expressions: http://stackoverflow.com/questions/1732348/regex-match-open-...
Just send it in cleartext, but over properly verified https.
That being said, look at something like blockchain.info.
It adds javascript security on top of https, and for (what seems like) excellent reasons.