Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Skrypt, który nie działa
gg1985
post
Post #1





Grupa: Zarejestrowani
Postów: 174
Pomógł: 3
Dołączył: 23.02.2008

Ostrzeżenie: (0%)
-----


Witam

Napisałem sobie taki skrypt walidujący formularz, jeśli user wpisze w pole "Adam" to formularz ma się zatwierdzić, ale się nie zatwierdza:

Kod
<script type="text/javascript">
$(function() {
$('#submit').click(function() {
var Val = $('#adam').attr('value');
if(Val != "adam" && Val != "Adam")
alert('Małysz ma na imię Adam');
else {
var form=document.forms[0];
form.submit();
}
});
})
</script>


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
pawkow
post
Post #2





Grupa: Zarejestrowani
Postów: 76
Pomógł: 7
Dołączył: 30.09.2006

Ostrzeżenie: (0%)
-----


Kod
<script type="text/javascript">
$(function() {
    $('#form_adam').submit(function() {
        if ($("#imie").val() != 'Adam')
        {
            alert('Małysz to Adam');
            return false;
        }
    });
})
</script>

<form id="form_adam" action="?" method="post">
    <input type="text" name="imie" id="imie" />
    <input type="submit" />
</form>


pisane z palca, sprawdź
Go to the top of the page
+Quote Post
gg1985
post
Post #3





Grupa: Zarejestrowani
Postów: 174
Pomógł: 3
Dołączył: 23.02.2008

Ostrzeżenie: (0%)
-----


Super, działa.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 15:47