Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi,

I'm trying to build a form that has client and server side validation, the problem I'm having is that in order to do this I need to mark fields as required so that I can use HTML5 validation, this isn't working I'm assuming because the required attribute is already in use by Couch? When I add an extra required attribute nothing happens.

Example as below:

Code: Select all
<cms:input type="text" name="csname" class="input" placeholder="Please enter a name" required='1' required />


This generates:

Code: Select all
<input type="text" name="csname" id="csname" value="" class="input" placeholder="Please enter a name">


But I need:

Code: Select all
<input type="text" name="csname" id="csname" value="" class="input" placeholder="Please enter a name" required>


Any ideas?

Thanks,

Chris
Hi,

You are right - Couch consumes that attribute as its own and so it does not get passed on as HTML.
For such cases, the workaround is to surround the problem attribute within double-quotes (Couch passes on such attributes without any change).

So, for your case we can use the following -
Code: Select all
<cms:input type="text" name="csname" class="input" placeholder="Please enter a name" required='1' "required" />

Which would result in the following output -
Code: Select all
<input type="text" name="csname"  id="csname" value=""  class="input" placeholder="Please enter a name" required/>

Hope this helps.
Amazing, thank you so much.
Welcome :)
Just on this - is there any way of having the type as "email"?

It's just that the client side validation doesn't work with an email address in a text field it just processes it as valid.
Please see the following thread for HTML5 Input Types like email -
viewtopic.php?f=8&t=9781

Hope this helps.
6 posts Page 1 of 1