Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style type="text/css">
- .success_brd{
- border:1px solid green
- }
- </style>
- <script type="text/javascript">
- //////////////// This update checks all empty fields ////////////
- //function checks for empty fields
- function CheckEmpty(field_id){
- var MyValue = document.getElementById(field_id);
- if(MyValue.value == "" || MyValue.value == null){
- //code
- displayWarning(field_id, MyValue.parentNode.id, "You can't leave this empty.");
- }
- else {
- removeWarning(field_id, MyValue.parentNode.id);
- }
- }
- //////////////// This update will validate the checkbox ////////////
- //function checks the checkboxes
- function ValidateCheckbox(checkbox){
- var check_box = document.getElementById(checkbox);
- if(check_box.checked == false){
- //code
- displayWarning(checkbox, check_box.parentNode.parentNode.id, "You must agree to proceed.");
- }
- else {
- removeWarning(checkbox, check_box.parentNode.parentNode.id);
- }
- }
- //////////////// This is an update to confirm the selection list ////////////
- //function validates the selections
- function ValidateSelect(select){
- //code
- selected = document.getElementById(select);
- if(selected.selectedIndex == 0){
- //code
- displayWarning(select, selected.parentNode.id, "Please select your country.");
- }
- else {
- removeWarning(select, selected.parentNode.id);
- }
- }
- //////////////// This is a new function ////////////
- //function remove error message
- function removeWarning(field_id, parent_div){
- var error_element = document.getElementById(parent_div).querySelectorAll(".warning_msg");
- if (error_element.length > 0){
- error_element[0].parentNode.removeChild(error_element[0]);
- document.getElementById(field_id).classList.remove("warning_brd");
- }
- document.getElementById(field_id).className += " success_brd";
- }
- </script>
Add Comment
Please, Sign In to add comment