This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disable "Validate" button until URL is wellformed (bug 731131)
- Loading branch information
Showing
1 changed file
with
6 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,9 @@ $(document).ready(function() { | |
if($('#upload-webapp-url').exists()) { | ||
$('#upload-webapp-url').bind("keyup change paste blur", function(e) { | ||
var $this = $(this), | ||
$button = $('#validate_app'); | ||
$button = $('#validate_app'), | ||
// Ensure it's at least "protocol://host/something". | ||
match = $this.val().match(/^(.+):\/\/(.+)/); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cvan
Author
Contributor
|
||
|
||
if($this.attr('data-input') != $this.val()) { | ||
// Show warning if 8+ characters have been typed but there's no protocol. | ||
|
@@ -62,9 +64,9 @@ $(document).ready(function() { | |
.parent().removeClass('show-tip'); | ||
} | ||
|
||
if ($this.val()) { | ||
$button.removeClass('disabled'); // show validate btn | ||
} | ||
// Show the button if valid. | ||
$button.toggleClass('disabled', !match); | ||
|
||
$this.attr('data-input', $this.val()); | ||
$('#upload-status-results').remove(); | ||
$('#upload-file button.upload-file-submit').attr('disabled', true); | ||
|
Aren't you creating a copy of the regular expression on each key press? Is that expensive? Why not pull that out and into a var?
var regexp = /^(.+):\/\/(.+)/;
and then$this.val().match(regexp)
?