Skip to content

Instantly share code, notes, and snippets.

View CSFelix's full-sized avatar
🤔
https://contra.com/_csfelix08_

CSFelix CSFelix

🤔
https://contra.com/_csfelix08_
View GitHub Profile
<!--
some types of input tags in HTML have the 'pattern attribute' available
this attribute is used to check some RegEx (Regular Expression), for example, check email, nickname and password
in this example, consider that I have a form with one nickname field, this field must accept just letters,
underscores and numbers. Also, the nickname must have legnth between 5 - 15 chars. I would tip like this: [a-zA-Z1-9_]{5,15}
-->
<form method="POST" action="#">
<input type="text" title="Only letters, underscores and numbers are accepted. You must tip betwenn 5 - 15 chars"
pattern="[a-zA-Z1-9_]{5,15}" required>
<input type="submit" value="Save!">
@CSFelix
CSFelix / ajax.jsp
Last active September 29, 2020 14:42
<script>
// suppose that I have a form with two fields: 'email' and 'password'
// to use ajax, first I needa catch the values of these fields like this (I'm using JQuery)
var email = $("#emailField").val();
var password = $("#passwordField").val();
// check if the fields are filled
if (email == "" || password == "") { alert("Both fields need be filled"); }
else {
// now, I active Ajax when the 'submit' button are clicked
// design mode allows you try websites out editing its contents (like ContentEditable attribute in HTML's tags)
// you can put bold, italic and common texts and add another contents (it's usefull when you program with TomCat like me LOL)
// to use design mode, just opens Inspect Element Window in the website, go to Console tab an tip this command
document.designMode = "on";
// to desable it, tip this
document.designMode = "off";
@CSFelix
CSFelix / immortal_dino.js
Created September 21, 2020 20:12
Immortal Dino Game
// access chrome://dino in you Google Chrome Browser
// inspect element and go to console
// tip each command below
// close the Inspect Element's Window
// start the game and the dino wont'b be effected with cactus and birds
var original = Runner.prototype.gameOver;
Runner.prototype.gameOver = function() { };