HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Validating a year field

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#70588
Avatar

ocStaff (admin)

what's the full fields.xml file look like?



Become a fan of ocPortal on Facebook or add me as a friend.

Expand: Was I helpful? Was I helpful?

Expand: Follow me on Twitter Follow me on Twitter







If I answered something that you think should be in the documentation, please take the initiative and add it to the community documentation. We really need people to help out here and build a well-organised large support resource.
Back to the top
 
Posted
Rating:
#70625
Avatar

Community saint

Chris-

The fields.xml has the base as delivered which I have kept for reference and my entry at the very top. I am including it as an attachment since the word filter catches some of what the base includes.

Attachment
Fields.xml file
» Download: fields.xml.txt (2 Kb, 35 downloads so far)




Thanks much for your help.

Bob
Back to the top
 
Posted
Rating:
#70659
Avatar

ocStaff (admin)

Hmm, it did work for me - I submitted and got an 'Entry too long' error when I put 5 digits into the field.
Maybe the 'xml_fields' addon is not installed?



Become a fan of ocPortal on Facebook or add me as a friend.

Expand: Was I helpful? Was I helpful?

Expand: Follow me on Twitter Follow me on Twitter







If I answered something that you think should be in the documentation, please take the initiative and add it to the community documentation. We really need people to help out here and build a well-organised large support resource.
Back to the top
 
Posted
Rating:
#70715
Avatar

Community saint

Okay, got that working. I was testing while editing an entry.

How do I add validation to editing an entry? DO I just add "ed,_ed" to the types field?

Thanks for any help.

Bob
Back to the top
 
Posted
Rating:
#70718
Avatar

ocStaff (admin)

Pretty much. Look at the URLs present, can't remember off-hand what it is, but it is whatever type= is set to in the URL (or if short URLs are on, it's part of the path).



Become a fan of ocPortal on Facebook or add me as a friend.

Expand: Was I helpful? Was I helpful?

Expand: Follow me on Twitter Follow me on Twitter







If I answered something that you think should be in the documentation, please take the initiative and add it to the community documentation. We really need people to help out here and build a well-organised large support resource.
Back to the top
 
Posted
Rating:
#70719
Avatar

Community saint

The two URLs ("Edit this" and "Edit one) are, respectively:

Code

http://xxxxxxxx.com/cms/cms_catalogues/_edit_entry/11.htm?catalogue_name=image_galleries&keep_session=4715205&keep_no_swfupload=1

http://xxxxxxxx.com/cms/cms_catalogues/edit_entry.htm?catalogue_name=image_galleries

This is the current entry in fields.xml:

Code

<qualify pages="cms_catalogues" types="ad,_ad,_edit_entry,edit_entry" fields="field_45">
      <minLength error="Entry too short">3</minLength>
      <maxLength error="Entry too long">4</maxLength>
      <possibilitySet error="Year too early or too late!">1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000</possibilitySet>
   </qualify>

It works properly when adding an item however when editing the item, it does not validate the number on save. If I select "Edit this" immediately after, I do get an error message. I don't get any error message if I select "Edit one".

Also, I seem to always get the possibilitySet error message even if the year is too short. How is precedence handled? Should I put the possibiltySet first?

Thanks for the help.

Bob
Back to the top
 
Posted
Rating:
#70793
Avatar

ocStaff (admin)

_edit_entry,edit_entry should be __edit_entry,_edit_entry

Precedence is undefined.



Become a fan of ocPortal on Facebook or add me as a friend.

Expand: Was I helpful? Was I helpful?

Expand: Follow me on Twitter Follow me on Twitter







If I answered something that you think should be in the documentation, please take the initiative and add it to the community documentation. We really need people to help out here and build a well-organised large support resource.
Back to the top
 
Posted
Rating:
#70818
Avatar

Community saint

Chris-

I made the change you suggested to the qualify in fields.xml but the error described above continues:
It works properly when adding an item however when editing the item, it does not validate the number on save. If I select "Edit this" immediately after, I do get an error message. I don't get any error message if I select "Edit one"

I get no error message when editing the year to 196 but do get the error when I use the "Edit this" immediately afterwards.
 
Bob
Back to the top
 
Posted
Rating:
#70828
Avatar

ocStaff (admin)

Actually looking at the URL it's '__ed'.



Become a fan of ocPortal on Facebook or add me as a friend.

Expand: Was I helpful? Was I helpful?

Expand: Follow me on Twitter Follow me on Twitter







If I answered something that you think should be in the documentation, please take the initiative and add it to the community documentation. We really need people to help out here and build a well-organised large support resource.
Back to the top
 
Posted
Rating:
#70831
Avatar

Community saint

That's seems to have fixed it.

I've simplified the <qualify> statement to just the possibilitySet since it includes a discrete set of accepted values.

Thanks for your help, Chris.

Bob
Back to the top
 
Posted
Rating:
#71036
Avatar

Community saint

Well, I realized this is not going to work because one of the potential answers is "Unknown" which means I need to change this from a numeric field to a text field with no Comcode cupport. My problem now is that the year is padded by leading 0s and displayed that way.

Shouldn't a text field be displayed as it is entered?

Bob
Back to the top
 
Posted
Rating:
#71052
Avatar

ocStaff (admin)

Well you don't need it to be a number field for your validation because you've inputted your conclusive possibility-set.

Regarding the leading zeros, that is how it is saved for a numeric field, but if you remove them now they will stay removed.



Become a fan of ocPortal on Facebook or add me as a friend.

Expand: Was I helpful? Was I helpful?

Expand: Follow me on Twitter Follow me on Twitter







If I answered something that you think should be in the documentation, please take the initiative and add it to the community documentation. We really need people to help out here and build a well-organised large support resource.
Back to the top
 
Posted
Rating:
#71072
Avatar

Community saint

The problem with this is that these fields are entered by members and I'd prefer not to validate each entry because I want the results immediately available.  

Any chance of a coding solution to address this?

Bob
Back to the top
 
Posted
Rating:
#71075
Avatar

Community saint

I'm just going to change this back to a numeric field and instruct people to enter '0000' is the painting's date is unknown.

A bit less obvious but it should work.

Bob
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: