'Check whether the input is a valid ID Card Number.'

def clean(self, value):

    super(CNIDCardField, self).clean(value)
    if (not value):
        return u''
    if (not re.match(ID_CARD_RE, value)):
        raise ValidationError(self.error_messages[u'invalid'])
    if (not self.has_valid_birthday(value)):
        raise ValidationError(self.error_messages[u'birthday'])
    if (not self.has_valid_location(value)):
        raise ValidationError(self.error_messages[u'location'])
    value = value.upper()
    if (not self.has_valid_checksum(value)):
        raise ValidationError(self.error_messages[u'checksum'])
    return (u'%s' % value)
