Skip to content

Instantly share code, notes, and snippets.

@jsam
Created March 29, 2013 03:58
Show Gist options
  • Save jsam/5268677 to your computer and use it in GitHub Desktop.
Save jsam/5268677 to your computer and use it in GitHub Desktop.
Match passwords
JS
function validatePass(p1, p2)
{
if (p1.value != p2.value || p1.value == '' || p2.value == '')
{
p2.setCustomValidity('Password incorrect');
} else {
p2.setCustomValidity('');
}
}
HTML
input(type="password", name="new_password", id="p1", ng-model="user.new_password", required)
label Repeat Password
input(type="password", name="new_password_repeat", onfocus="validatePass(document.getElementById('p1'), this)", oninput="validatePass(document.getElementById('p1'), this)", required)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment