This file contains hidden or 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
| function unscramble(word) { | |
| //import dictionary | |
| const dict = require('an-array-of-english-words'); | |
| } |
This file contains hidden or 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
| function unscramble(word){ | |
| /* This function unscrambles a word | |
| * @word: This is the word to unscramble | |
| */ | |
| } |
This file contains hidden or 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
| function calcDate(date1, date2) { | |
| /* | |
| * calcDate() : Calculates the difference between two dates | |
| * @date1 : "First Date in the format MM-DD-YYYY" | |
| * @date2 : "Second Date in the format MM-DD-YYYY" | |
| * return : Array | |
| */ | |
| //new date instance | |
| const dt_date1 = new Date(date1); |
This file contains hidden or 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
| <?php | |
| //define validation rules | |
| $valRules = array( | |
| "username" => array( | |
| ["R", "Your username is required"], | |
| ["UNAME"] | |
| ), | |
| "email" => array( | |
| ["R", "Your Email is required"], | |
| ["EMAIL", "Your Email is invalid"] |
This file contains hidden or 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
| <?php | |
| $valRules = array( | |
| "age" => array( | |
| ["LENGTH", "2", "Your age must be 2 digits"] | |
| ) | |
| ); | |
| ?> |
This file contains hidden or 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
| <?php | |
| //syntax | |
| $valRules = array( | |
| "FORM_INPUT_NAME" => array( | |
| ["ATTRIBUTE_TITLE", "VALUE", "CUSTOM_ERROR_MESSAGE"] | |
| ) | |
| ); | |
| ?> |
This file contains hidden or 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
| <?php | |
| //custom rules | |
| $customRules = array( | |
| "UNAME" => ['/simon/', "You must enter simon"], | |
| "PASS" => ['/12345/', "You must enter 12345"] | |
| ); | |
| //build the rules | |
| $DemoForm->moreCustomRules($customRules); | |
| //redefine validation rules |
This file contains hidden or 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
| <?php | |
| //custom rules | |
| $customRules = array( | |
| "UNAME" => ['/simon/', "You must enter simon"], | |
| "PASS" => ['/12345/', "You must enter 12345"] | |
| ); | |
| //build the rules | |
| $DemoForm->moreCustomRules($customRules); | |
| ?> |
This file contains hidden or 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
| <?php | |
| //require library | |
| require 'octaValidate-php/src/Validate.php'; | |
| use Validate\octaValidate; | |
| //create new instance of the class | |
| $DemoForm = new octaValidate('form_demo'); | |
| //define validation rules | |
| $valRules = array( | |
| "username" => array( |
This file contains hidden or 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
| <?php | |
| //begin validation | |
| if ($DemoForm->validateFields($valRules, $_POST) === true){ | |
| //process form data here | |
| }else{ | |
| //retrieve & display errors | |
| print('<script> | |
| window.addEventListener(\'load\', function(){ | |
| showErrors(' . $DemoForm->getErrors() . '); | |
| }) |