Witam mam formularz, który działa prawidłowo chciałbym jednak zrobić warunek, że w polu input musi być wpisany znak: @. Dzięki
<script type="text/javascript">
function hide(x){x.value=''}
</script>
<script type="text/javascript">
function error(tekst) {
if (errfound) return;
errfound = true;}
function validate(id) {
errfound = false;
var errors = "";
if (document.getElementById('description').value == ""){errors += "description is empty. \n";document.getElementById('description').style.backgroundColor = "#FFDFDF";}
else {document.getElementById('description').style.backgroundColor = "#b9fdbb";}
if (document.getElementById('mail').value == ""){errors += "description is empty. \n";document.getElementById('mail').style.backgroundColor = "#FFDFDF";}
else {document.getElementById('mail').style.backgroundColor = "#b9fdbb";}
if (errors != "") error(errors); return !errfound;}
</script>
<input type="text" class="textinput" name="mail" id="mail" onfocus="hide(this)" value="Twój e-mail" />
W PHP sprawdzenie robię tak:
<?php
$tekst = 'jakiś tekst zawierający.';
if(strpos($tekst, '@')!==false) {echo 'zawiera';} else {echo 'nie zawiera';} ?>
Ten post edytował tenloginjestzajety 17.10.2016, 20:43:46
Nigdy nie zapominam kliknąć "pomógł". Zastosowanie na stronie [prosze nie spamuj]