I know how to ad custom fields to it, but how do i force people to fill them?
You could do a javascript check and make sure the fields are filled in before allowing the form to post, or you could check the post variables and redirect back to the previous page if they aren't complete.
I would like to use same method as those default fields have. I just dont know how :D
Lainaus käyttäjältä: Owdy - helmikuu 28, 2006, 02:33:13 IP
I would like to use same method as those default fields have. I just dont know how :D
Yup, thats Javascript.
Do you just want to vrafy the field is not empty or what?
If just empty then adding this to the input tags will do it:
onclick="if (this.value == '') { alert('Please fill in this field!'); this.focus(); }"
If not then can you be a bit more specific ?
Cheers,
Ryan Jones
That seems perfect. But if i ad that to input tag, i get parse errors. I suck with JS :(
Look how Oldiesmann did a great job in the past: Registering new members settings? (http://www.simplemachines.org/community/index.php?topic=53389.0)
If you really want to make sure that the field is inputted then you'll have to edit the source file. Javascript alone just won't cut it.
So say you had:
What is your shoe size: <input type="text" name="shoe_size" />
Then you'd do something like this in the source file
if ( !isset($_REQUEST['shoe_size']) || trim($_REQUEST['shoe_size']) == '' )
fatal_error("Hey jerk I said give me your shoe size", false);
REQUEST can be exchanged with POST if you want to limit it to post only. The false on the fatal error means it won't log the error. Using trim keeps people from just putting in spaces or other whitespace.
I got this
<input type="text" name="options[text_location]" size="50" value="', isset($context['member']['options']['text_location']) ? $context['member']['options']['text_location'] : '', '" tabindex="', $context['tabindex']++, '" />
If i put this to Register.php, it wont work.
if ( !isset($_REQUEST['text_location']) || trim($_REQUEST['text_location']) == '' )
fatal_error("Ammatti unohtui!", false);
Try this...
Find: redirectexit('action=coppa;member=' . $memberID);
After, Add: if ( !isset($_POST['text_location']) || trim($_POST['text_location']) == '' )
fatal_error("Ammatti unohtui!", false);
See if that works for you :)
Cheers,
Ryan Jones
No. :( It gives that error 'ammatti unohtui' and gives link back, but it registers member anyway. Hmmm, how about that just js error, im fine with that if it works.
It helps if you use the same name....
$_REQUEST['text_location'] is in your source but you have "options[text_location]" in your form. That would make it $_REQUEST['options']['text_location']
Its still does the same. It gives an error, and if you hit 'back' link and try again it says you cannot register twice. Thats because that allows register go trough somehow.
edit: i got it, Thanks! It was in wrong area. It works like this:
// omat säädöt
if ( !isset($_REQUEST['options']['text_location']) || trim($_REQUEST['options']['text_location']) == '' )
fatal_error("Ammatti unohtui!", false);
// Registration options are always default options...
if (isset($_POST['default_options']))