Jump to content

Required field left blank


hairydog

Recommended Posts

I found a customer having problems with Stripe payment.

It turned out that she had put her mobile number into the Mobile field and left the Phone field blank. And Stripe wanted a 'phone' number!

I was puzzled how she had registered without an entry in the Phone field, which is required. 

When I tried to repeat this by leaving Phone blank and clicking Register I found that instead of a nice error message, I got a white screen 500 error. But nevertheless, the account was created, complete with a blank Phone field.

For now, I've removed the Mobile field from the Register screen to reduce the chance of this happening, but the 500 error isn't right. 

How are missing required fields meant to be handled?

The site in question is https://www.rosecottage.org.uk/shop

Later: I had a bit of a twiddle about, fixed nothing, but now no 500 error. However, the Phone field still isn't being Required. You can leave it blank and still register. The other fields work just fine.

Edited by hairydog
update
Link to comment
Share on other sites

From the HTML, I see that the phone field is wanting to be required, that is, you have every intention of making this a required field.

However, CubeCart does not care (See User->registerUser() function).

I see class="textbox required", but I do not find any javascript that would manage this class as a required field.

If the field were coded as follows:

<input required placeholder="phone number" name="phone" id="register-phone" class="textbox required" value="" type="phone">

That is, use the tag's required attribute instead of (or in addition to) the value for the class attribute. Thus, HTML5 will enforce the required entry.

I also notice that the CSS for input.required (common.css, line 283) is being overruled by an !important attribute on input (line 278). You may want to consider moving the border color out of that combined declaration and give it a separate border-color declaration.

Also, according to W3Schools.com, there is no <input type="phone">. I very much doubt this would cause a 500ISE.

Link to comment
Share on other sites

I think you have brushed close past the answer. I don't want to use the html required because the CC way is more elegant. Is there an easy way to make CC require an additional field? 

I'll have a look at the border CSS declaration. I don't remember how or why it is like that.

The phone type may not be in the spec, but it works!

[later] I decided to take your advice about the required which works better than I had expected. Thanks very much.

And I have switched the type="phone" to type="tel" although both do seem to work OK, getting it right is a good approach, really.

No idea why there was an !important on line 278. It may be a hangover from a battle with Google Chrome's cacheing!

Edited by hairydog
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...