supporter: HTML5 improvements to form.

* Use "number" type for a better prompt.
* Use new standard "min" attribute for richer validation.
This commit is contained in:
Brett Smith 2016-12-02 12:35:19 -05:00
parent 4afce1eadc
commit d28ffd68ca
2 changed files with 4 additions and 4 deletions

View file

@ -117,7 +117,7 @@ $(document).ready(function() {
noCommaValue = value.replace(/,/g, "");
var re = /^((\d{1,3}(,?\d{3})*?(\.\d{0,2})?)|\d+(\.\d{0,2})?)$/;
var isValid = ( re.test(value) &&
parseInt(noCommaValue) >= parseInt(input.attr("minimum")));
parseInt(noCommaValue) >= parseInt(input.attr("min")));
if (isValid) {
input.removeClass("invalid").addClass("valid");
errorElement.removeClass("form-error-show").addClass("form-error");

View file

@ -69,7 +69,7 @@
<input type="hidden" name="item_name" value="Conservancy Supporter, Annual" />
<input id="no_shipping" type="hidden" name="no_shipping" value="0" />
<label for="amount"><strong>Amount:</strong> $</label>
<input id="amount" type="text" name="amount" size="7" minimum="120" value="120" />
<input id="amount" type="number" name="amount" size="7" min="120" value="120" />
<span id="error" class="form-error-show">$120 is a minimum for Conservancy
Supporters. <a href="/donate">Donate smaller amounts here</a>.</span><br/>
@ -138,7 +138,7 @@
<input type="hidden" name="srt" value="0" />
<input type="hidden" name="item_name" value="Conservancy Supporter, Monthly" />
<label for="amount"><strong>Monthly Amount:</strong> $</label>
<input id="amount" type="text" name="a3" size="5" minimum="10" value="10" />
<input id="amount" type="number" name="a3" size="5" min="10" value="10" />
<span id="error" class="form-error-show">$10/month is a minimum for Conservancy
Supporters. <a href="/donate">Donate smaller amounts here</a>.</span><br/>
<label for="wantGift"><strong>Do you want to receive a t-shirt? </strong></label>
@ -197,7 +197,7 @@
<input type="hidden" name="item_name" value="Conservancy Supporter, Annual Renewal" />
<input id="no_shipping" type="hidden" name="no_shipping" value="0" />
<label for="amount"><strong>Amount:</strong> $</label>
<input id="amount" type="text" name="amount" size="7" minimum="120" value="120" />
<input id="amount" type="number" name="amount" size="7" min="120" value="120" />
<span id="error" class="form-error-show">$120 is a minimum for Conservancy
Supporters. <a href="/donate">Donate smaller amounts here</a>.</span><br/>