Snippet List
The original USPhoneNumberField only validates xxx-xxx-xxxx values.
This field validates...
> (xxx) xxx xxxx
> xxx-xxx-xxxx
> (xxx)-xxx-xxxx
> many others.
**Explanation of the regular expression:**
1. Accepts either (xxx) or xxx at the start of the value.
2. Allows for any amount of dashes and spaces (including none) before the next set of digits.
3. Accepts 3 digits
4. Allows for any amount of dashes and spaces (including none) before the next set of digits.
5. Accepts 4 digits, finishing the value.
This field saves in the same format that the original USPhoneNumberField does (xxx-xxx-xxxx).
Enjoy!
- forms
- validation
- field
- phone
This is a generic unique field value validator for use with newforms. ( It's handy to plug into newforms-admin.)
Example, with newforms-admin:
`
class LinkAdminForm( ModelForm ):
def clean_url( self ):
return isUnique( self.instance, 'url', self.cleaned_data['url'])
class LinkAdmin( ModelAdmin ):
form = LinkAdminForm
site.register( Link, LinkAdmin )
`
This filter converts a XHTML-compatible shorttag `<input ... />` to a HTML4-compatible tag `<input ...>`.
Example:
`{% for field in form %}
<dt>{{ field.label_tag }}</dt>
<dd>
{{ field.errors }}
{{ field|remove_shorttag }}
</dd>
{% endfor %}`
This will produce html4-compatible output, opposed to newform's normal XHTML output.
- newforms
- html
- xhtml
- html4
- shorttag
clamothe has posted 3 snippets.