/
Forside
/
Teknologi
/
Udvikling
/
PHP
/
Nyhedsindlæg
Login
Brugernavn
*
Kodeord
*
Husk mig
Brugerservice
Kom godt i gang
Bliv medlem
Seneste indlæg
Stil et spørgsmål
Skriv et tip
Pointsystemet
Kontakt Kandu.dk
Emnevisning
Kategorier
Alfabetisk
Karriere
Interesser
Teknologi
Reklame
Top 10 brugere
PHP
#
Navn
Point
1
rfh
3959
2
natmaden
3372
3
poul_from
3310
4
funbreak
2700
5
stone47
2230
6
Jin2k
1960
7
Angband
1743
8
Bjerner
1249
9
refi
1185
10
Interkril..
1146
QF - conditional elements requiring condit~
Fra :
Tommy Ipsen
Dato :
15-04-04 16:13
Hi
I have the following form fields generated by QuickForm:
<select onchange="this.form.url_manual.disabled=this.selectedIndex!=0;" name="url_automatic">
<option value="none">Ekstern side</option>
<option value="url1">Link to URL1</option>
<option value="url2">Link to URL2</option>
<option value="url3">Link to URL3</option>
</select>
<input value="Type URL" onchange="this.form.url_automatic.disabled=(this.value!='' &&
this.value!=this.defaultValue);" name="url_manual" type="text" />
These two fields are mutually exclusive meaning that either you choose an option from the drop-down
menu or you type in a value in the text field.
Now I want to add a crude validation to the text field helping the user to type in a correct URL and
I've reached the following:
$form->registerRule('url', 'regex',
'/(^(ldap|http|https|ftp):\/\/(([a-z0-9\-\.]+\.+[a-z]{2,6})|([0-9]{1,3}\.){4})(\]?)$)/');
But the problem is that an URL is ONLY required IF the first/default option from the drop-down menu
is active - if any other element is chosen, the text field is disabled and the rule shouldn't trigger!
How can I accomplish this behaviour using QuickForm?
Regards,
Tommy Ipsen
Søg
Alle emner
Teknologi
Udvikling
PHP
Indstillinger
Spørgsmål
Tips
Usenet
Reklame
Statistik
Spørgsmål :
177821
Tips :
31980
Nyheder :
719565
Indlæg :
6410977
Brugere :
218912
Månedens bedste
Årets bedste
Sidste års bedste
Copyright © 2000-2026 kandu.dk. Alle rettigheder forbeholdes.