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 89b112ea95
commit 409f3f7fbe
No known key found for this signature in database
GPG Key ID: 2D9B32E54C68A3FB
3 changed files with 12 additions and 1 deletions

View File

@ -532,6 +532,8 @@ class Tab(QtWidgets.QWidget):
return self.share_mode
elif self.mode == self.common.gui.MODE_RECEIVE:
return self.receive_mode
elif self.mode == self.common.gui.MODE_CHAT:
return self.chat_mode
else:
return self.website_mode
else:

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();

View File

@ -28,7 +28,7 @@
<div class="chat-users">
<div class="editable-username">
<input id="username" value="{{ username }}" />
<button id="update-username">Save</button>
<button id="update-username" disabled>Save</button>
</div>
<ul id="user-list">
</ul>