Well folks, I wanted to make a form where in an input it is mandatory to put a Steam link. How do I do? Thank you.
Well folks, I wanted to make a form where in an input it is mandatory to put a Steam link. How do I do? Thank you.
By tag jquery-validation-engine I assume you're using jquery jquery.validationEngine.js
plank, if that's true then first download the files at link (if necessary).
If the field is required:
class="validate[required,custom[url]] text-input"
If the field is optional:
class="validate[custom[url]] text-input"
Use should look something like:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css"/>
<script src="../js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="../js/languages/jquery.validationEngine-pt-br.js" type="text/javascript"></script>
<script src="../js/jquery.validationEngine.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function(){
jQuery("#meuFormulario").validationEngine();
});
</script>
</head>
<body>
<form id="meuFormulario" class="formular" method="post">
<label>
<span>Field is optional : </span>
<input value="" class="validate[custom[url]] text-input" type="text" name="optional" id="optional" />
</label>
<button>Enviar</button>
</form>
</body>
</html>
Now if you really want to check if the link is from Steam, you can create your own validator, for example in HTML do something like:
<input value="" class="validate[required,funcCall[checarLinkSteam]] text-input" type="text" id="linksteam" name="linksteam" />
If the link is from a profile you can validate with regex like this (in this example you accept id
and url with profile
):
/^http://steamcommunity\.com/(id|profile)/([^/]+)$/.test(...)
If it is a link of any of the steam you can validate like this:
/^http://steamcommunity\.com/([^/]+)$/.test(...)
In the script add:
<script>
jQuery(document).ready(function(){
jQuery("#meuFormulario").validationEngine();
});
function checarLinkSteam(field, rules, i, options){
//Valida se é um profile (o ! na frente é para negação, basico uso de IFs)
if (!/^http://steamcommunity\.com/(id|profile)/([^/]+)$/.test(field.val())) {
return options.allrules.validate2fields.alertText;
}
}
</script>
</head>
Based on examples: link
Specifically the field being a steam link does not exist anything that I know, but at the beginning you can use , to specifically check if the user is inputting a link, you can later do a Checking the typed string using some javascript function, here are some solutions. How can I check if a string does it contain another in Javascript?