Show if
Dear Jason, I’m back at the registration page – just when I thought here were sorted. I’m adding some extra server-side validation – in particular some validation to work on the email field so as to avoid duplications in the database table – so I’m using ‘unique database value’ server validation.
Note: I’ve turned off Javascript in Firefox.
PROBLEM 1
Firstly, in my CSS Form Builder ‘Registration form’, I’ve added an extra ‘show if’ validation for the ‘unique database value’ and that works. I have noticed in the code that it did not add any ‘span or an id’ like in the other show if message for the same filed that CSS Form Builder added – so I need to have a class and an id. I probably need the class for the colour, but what is, and how is, the ‘id’ generated – see code below:
Email Validation code:
<?php
if (ValidatedField('register','register')) {
if ((strpos((",".ValidatedField("register","register").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="Email_Address_ServerError">Please enter email address.</span>
<?php //WAFV_Conditional register.php register(1:)
}
}
}?>
<?php
if (ValidatedField('register','register')) {
if ((strpos((",".ValidatedField("register","register").","), "," . "13" . ",") !== false || "13" == "")) {
if (!(false)) {
?>
Email address already registered!
<?php //WAFV_Conditional register_test.php register(13:)
}
}
In addition, apart from the ‘already registered’ message appearing in black, it is not properly aligned like the ‘please enter an email’ message – screenshots attached.
PROBLEM 2
I was going to add another validation for invalid email entries and have a show if saying (not a valid email) - is this overkill on the validation. Anyway, as things stand, with two validations on this email field, if the field is left bank and I hit submit, all two ‘show if’ messages appear (see attached screenshots), so I imagine if I had another ‘show if’ message, all three would appear. How can this be avoided so that if the field is left blank only the ‘show if’ - please enter an email – appears?
PROBLEM 3
I watched your video ‘Add server validation to your web forms’. I have one question:
Why is the instructor hopping over to the confirm.php page to do the validations. Surely, the validation should be done on the checkout.php page – because that is where the information is entered? The instructor talks about the confirm.php page being the action page and then selects the confirm.php page when she is setting up the show if message, even though the message is on the checkout.php page – I don’t get it.