So we can make things easier by using javascript, for example, you can check if the value exists, if it exists, let it pass, otherwise, add, is a good one?
To check using javascript we can use the string.indexOf("blog") != -1
if it does not contain "blog" in the string, it returns -1, if it does, it returns the position of the string.
If you are using an input, we can take the value and check each typed letter, we can trigger a function to each typed letter by adding the tag onkeyup
for example, where we would check letter to letter.
Example for checking, remembering that use jquery to take the amount:
<input type="text" id="texto" onkeyup="checar()">
<script type="text/javascript">
function checar(){
if($("#texto").val().indexOf("blog") != -1){return true;}
}
</script>
We can check at the time of sending the form, and thus add in the string.
If you consider adding this automatically, you can relieve the user of this obligation and add it in PHP itself before recording it in the database. Something like:
$titulo .= ' blog';
– Sam
How would you do on the Laravel? i was considering using an html form, in which case I would have to take the exact value of the field in the validation to then add the tag (blog).
– Macedo_Montalvão
I don’t know anything about Laravel :/
– Sam
tranquil, php works too, I do a way here.
– Macedo_Montalvão