Changeset 33114 for main/trunk
- Timestamp:
- 2019-05-28T19:56:46+12:00 (5 years ago)
- Location:
- main/trunk/greenstone3/web
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/WEB-INF/classes/interface_default.properties
r33092 r33114 307 307 berry.send_success=Sending mail succeeded 308 308 berry.send_fail=Sending mail failed 309 berry.invalid_to_address_empty=The To address field cannot be empty. 310 berry.invalid_to_address=The To address field must contain an email address. 311 berry.invalid_msg_body_empty=The message body text field cannot be empty. 309 312 310 313 ################################## -
main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrycheckout.js
r33109 r33114 381 381 input.setAttribute("id", item); 382 382 input.setAttribute("class", "mailinput"); 383 input.setAttribute("type", "text"); 383 if(item === "address") { 384 input.setAttribute("type", "email"); // https://html5-tutorial.net/form-validation/validating-email/ 385 input.required = true; // https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript 386 } else { 387 input.setAttribute("type", "text"); 388 } 384 389 td.appendChild(input); 385 390 tr.appendChild(td); … … 437 442 input.setAttribute("id", item); 438 443 input.setAttribute("class", "mailinput"); 439 input.setAttribute("type", "text"); 444 if(item === "address") { 445 input.setAttribute("type", "email"); // https://html5-tutorial.net/form-validation/validating-email/ 446 input.required = true; // https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript 447 } else { 448 input.setAttribute("type", "text"); 449 } 440 450 td.appendChild(input); 441 451 tr.appendChild(td); … … 506 516 var parea = document.createElement('textarea'); 507 517 parea.id = 'pretextarea'; 508 518 parea.required = true; // https://www.w3schools.com/tags/att_textarea_required.asp 519 // and https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript 520 509 521 parent.appendChild(parea); 510 522 … … 607 619 var postdata = ""; 608 620 var i; 621 622 var content = YAHOO.util.Dom.get('pretextarea').value; 623 624 // To send an email, the To address and message Body must contain data. 625 // HTML5 input checking (required attribute) would make empty fields red outlined, 626 // but did not prevent Send button submitting form. So some basic sanity checking in JS: 627 // Checking non-empty and to address field must further be a URL: checking it contains @ 628 var to_address = YAHOO.util.Dom.get('address').value; 629 630 if(to_address.trim() === "") { 631 alert(gs.text.berry.invalid_to_address_empty); 632 return; 633 } else if(to_address.indexOf('@') === -1) { 634 alert(gs.text.berry.invalid_to_address); 635 return; 636 } else if(content.trim() === "") { 637 alert(gs.text.berry.invalid_msg_body_empty); 638 return; 639 } 640 609 641 //get checked items 610 642 for (i in mailinfo) { … … 614 646 } 615 647 616 var content = YAHOO.util.Dom.get('pretextarea').value;617 648 618 649 content = content.replace(/&/g,'-------');
Note:
See TracChangeset
for help on using the changeset viewer.