Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

Register template modification

Aloittaja Owdy, helmikuu 28, 2006, 02:29:41 IP

« edellinen - seuraava »

Owdy

I know how to ad custom fields to it, but how do i force people to fill them?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

kegobeer

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.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Owdy

I would like to use same method as those default fields have. I just dont know how :D
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

RyanJones

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
RyanJ (Ryan Jones)

Support Web Standards!

Currently working On: Additions to the Karma system.

Owdy

That seems perfect. But if i ad that to input tag, i get parse errors. I suck with JS :(
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Elmacik

Home of Elmacik

Thantos

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.

Owdy

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);


Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

RyanJones

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
RyanJ (Ryan Jones)

Support Web Standards!

Currently working On: Additions to the Karma system.

Owdy

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.
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Thantos

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']

Owdy

#11
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']))
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Advertisement: