disable Submit
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
* DISABLE SUBMIT
**/
function DisableS(id, NameField, NameForm)
{
if(document.getElementById(id).value.length > 0)
{
document.NameForm.NameField.disabled=true;
}
else
{
document.NameForm.NameField.disabled=false;
}
}
* DISABLE SUBMIT
**/
function DisableS(id, NameField, NameForm)
{
if(document.getElementById(id).value.length > 0)
{
document.NameForm.NameField.disabled=true;
}
else
{
document.NameForm.NameField.disabled=false;
}
}
ik zou hier de submitbutton disablen maar dat lukt niet...
de variabele id komt van een span die gegenereerd wordt door AJAX.
iemand enig idee?
je moet wel disabled in je button hebben, anders kan je hem niet true of false maken.
dan blijft hij disabled...
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
function DisableS(id, NameField, NameForm)
{
if(document.getElementById(id).value != null)
{
document.forms[NameForm].NameField.disabled=true;
}
else
{
document.forms[NameForm].NameField.disabled=false;
}
}
{
if(document.getElementById(id).value != null)
{
document.forms[NameForm].NameField.disabled=true;
}
else
{
document.forms[NameForm].NameField.disabled=false;
}
}
HTML-FORM:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<form method="post" action="formInOutput.php" name="ThisForm">
<table>
<tr>
<td>Username:</td>
<td><input id="UN" type="text" name="Name" value="" onKeyUp='checkLength(this.id), UsernameCheck(this.value), DisableS("UsedName", "register", "ThisForm")'/></td>
<td>Minimumlength: 5 characters <b><u><span id="UsedName"></span></u></b></td>
</tr>
<tr>
<td>Password:</td>
<td><input id="PW1" type="password" name="PW1" value="" onKeyUp='checkLength(this.id), checkDUP("PW2", this.id)'/></td>
<td>Minimumlength: 5 characters</td>
</tr>
<tr>
<td>Re-type password:</td>
<td><input id="PW2" type="password" name="PW2" value"" onKeyUp='checkDUP(this.id, "PW1")'/></td>
<td>Minimumlength: 5 characters</td>
</tr>
<tr>
<td>Email adress:</td>
<td><input id="mail1" type="text" name="Mail1" value="" onKeyUp='checkEmail(this.id), checkDUP("mail2", this.id), EmailCheckT(this.value), DisableS("UsedMail", "register", "ThisForm")'/></td>
<td>Confirmation email will be send. <b><u><span id="UsedMail"></span></u></b></td>
</tr>
<tr>
<td>Email again:</td>
<td><input id="mail2" type="text" name="Mail2" value="" onKeyUp='checkDUP(this.id, "mail1")'/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="register" value="Register" /></td>
<td> </td>
</tr>
</table>
</form>
<table>
<tr>
<td>Username:</td>
<td><input id="UN" type="text" name="Name" value="" onKeyUp='checkLength(this.id), UsernameCheck(this.value), DisableS("UsedName", "register", "ThisForm")'/></td>
<td>Minimumlength: 5 characters <b><u><span id="UsedName"></span></u></b></td>
</tr>
<tr>
<td>Password:</td>
<td><input id="PW1" type="password" name="PW1" value="" onKeyUp='checkLength(this.id), checkDUP("PW2", this.id)'/></td>
<td>Minimumlength: 5 characters</td>
</tr>
<tr>
<td>Re-type password:</td>
<td><input id="PW2" type="password" name="PW2" value"" onKeyUp='checkDUP(this.id, "PW1")'/></td>
<td>Minimumlength: 5 characters</td>
</tr>
<tr>
<td>Email adress:</td>
<td><input id="mail1" type="text" name="Mail1" value="" onKeyUp='checkEmail(this.id), checkDUP("mail2", this.id), EmailCheckT(this.value), DisableS("UsedMail", "register", "ThisForm")'/></td>
<td>Confirmation email will be send. <b><u><span id="UsedMail"></span></u></b></td>
</tr>
<tr>
<td>Email again:</td>
<td><input id="mail2" type="text" name="Mail2" value="" onKeyUp='checkDUP(this.id, "mail1")'/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="register" value="Register" /></td>
<td> </td>
</tr>
</table>
</form>
En wat zit er in NameForm? De waarde ThisForm?
nja ik had het met dit opgelost:
Code (php)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
if(value != "")
{
document.getElementById('submitbutton').disabled = false;
}
else
{
document.getElementById('submitbutton').disabled = true;
}
{
document.getElementById('submitbutton').disabled = false;
}
else
{
document.getElementById('submitbutton').disabled = true;
}
misschien heb je er wat aan?
oké...nu heb ik dat hij heel de tijd disabled it...dus het moet aan mijn if liggen ... :s
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
function DisableS(fieldid, buttonid)
{
if(document.getElementById(fieldid).value != null)
{
document.getElementById(buttonid).disabled=true;
}
else
{
document.getElementById(buttonid).disabled=false;
}
}
{
if(document.getElementById(fieldid).value != null)
{
document.getElementById(buttonid).disabled=true;
}
else
{
document.getElementById(buttonid).disabled=false;
}
}
Aan de functie aanroep geef je het id mee van het te controleren veld (de value hiervan mag niet leeg zijn) en het id van de submit button.
Null waarden hebben betrekking op pointers e.d; niet op de waarde van formuliervelden.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
function DisableS(id, NameField, NameForm)
{
if(document.getElementById(id).value != '')
{
document.forms[NameForm].NameField.disabled=true;
}
else
{
document.forms[NameForm].NameField.disabled=false;
}
}
{
if(document.getElementById(id).value != '')
{
document.forms[NameForm].NameField.disabled=true;
}
else
{
document.forms[NameForm].NameField.disabled=false;
}
}
Gewijzigd op 01/01/1970 01:00:00 door Martijn Wieringa
Dat maakt niet uit, heb ik al getest :)Naja, iig in Firefox werkt dat wel.. :)
De foutconsole in FF gaf aan dat NameForm/ NameField niet gevonden kon worden. Met de document.getElementById methode werkt het wel.