Keep save button disabled if changed username invalid

- Disabled till username not changed
- On change, if username is empty, then disabled
- On change, if username is changed back to previous, then disabled
- Else allow saving
This commit is contained in:
Saptak S 2020-05-10 01:55:31 +05:30
parent 52971ad371
commit 7935d07bb3
3 changed files with 12 additions and 1 deletions

View file

@ -34,6 +34,15 @@ $(function(){
emitMessage(socket);
});
// Keep buttons disabled unless changed or not empty
$('#username').on('keyup',function() {
if ($('#username').val() !== '' && $('#username').val() !== current_username) {
$('#update-username').removeAttr('disabled');
} else {
$('#update-username').attr('disabled', true);
}
});
// Update username
$('#update-username').on('click', function() {
var username = $('#username').val();