http://ellislab.com/expressionengine/user-guide/modules/safecracker/index.html#rules-my-field-name
Add additional validation rules to your fields. Separate multiple rules with the pipe | character. You may use the native CodeIgniter rules (required, matches, min_length, max_length, exact_length, alpha, alpha_numeric, alpha_dash, numeric, integer, is_natural, is_natural_no_zero, valid_email, valid_emails, valid_ip, valid_base64), and these additional ExpressionEngine-specific rules: valid_ee_date.
The safecracker documentation mentions that valid_ip can be used as a validation rule. I receive this in error when trying to use valid_ip validation on a field.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Safecracker_lib::$input
Filename: libraries/Form_validation.php
Line Number: 1038
Fatal error: Call to a member function valid_ip() on a non-object in /system/codeigniter/system/libraries/Form_validation.php on line 1038The snippet of code I am using.
{exp:safecracker site="site1" class="site_form" entry_id="{segment_2}" channel="test" author_only="yes" include_jquery="no" safecracker_head="no" error_handling="inline" rules:your_ip_address="integer|valid_ip"}Input inside of safecracker pair tags.
<label for="your_ip_address">IP Address</label>
<input type="text" id="your_ip_address" name="your_ip_address" value="{if your_ip_address}{your_ip_address}{if:else}{ip_address}{/if}" maxlength="45" tabindex="3">
{if error:your_ip_address}<span class="error">{error:your_ip_address}</span>{/if}