Guys I am stuck here in Codeigniter validation. The scenario is that I want to display all the error messages right below each respective input field and not all the error messages together on the top of the form. Could anyone help me, how to do this?
Check below mentioned code. This will help you.
<h5>Username</h5>
<?php echo form_error('username'); ?>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<h5>Password</h5>
<?php echo form_error('password'); ?>
<input type="text" name="password" value="<?php echo set_value('password'); ?>" size="50" />
<h5>Password Confirm</h5>
<?php echo form_error('passconf'); ?>
<input type="text" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" />
<h5>Email Address</h5>
<?php echo form_error('email'); ?>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
Use form_error() function to do that. As describe in manual
echo form_error('username');
All you have to do is put this line under the field where you want to see error message. Here username is the name of the form field
more details
https://www.codeigniter.com/user_guide/libraries/form_validation.html#showing-errors-individually
write below code after your text or drop-down field
<?php echo form_error('field_name','<div class="errorClass">','</div>');?>
Related
I am facing problem when installing magento on my xampp server. There is some path url issue which I have been facing. please look at the screenshot
chrome-extension://mcbpblocgmgfnpjjppndjkmgjaogfceg/fsCaptured.html
Open \app\design\install\default\default\template\install\config.phtml
Find the textbox where the base url is entered. It will be around line no 85 with name ‘config[unsecure_base_url]‘
Remove ‘validate-url’ from its class and save the file.
<li>
<label for="base_url"><?php echo $this->__('Base URL') ?> <span class="required">*</span></label><br />
<input type="text" name="config[unsecure_base_url]" id="base_url" value="<?php echo $this->getFormData()->getUnsecureBaseUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Base URL')) ?>" class="required-entry validate-url input-text" />
</li>
Replace with
<li>
<label for="base_url"><?php echo $this->__('Base URL') ?> <span class="required">*</span></label><br />
<input type="text" name="config[unsecure_base_url]" id="base_url" value="<?php echo $this->getFormData()->getUnsecureBaseUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Base URL')) ?>" class="required-entry input-text" />
</li>
4.Refresh installation page and continue.
Try check "Skip Base URL Validation Before the next step"
Take a look at Please enter a valid URL. Protocol is required (http://, https:// or ftp://) in Magento 1.9.2 installing?
hi i am new to magento.. i need some help..
i am able to add address fields in form in my view(phtml file) but that fields data is not being
saved . how could i be able to save those fields?
code for address field in phtml file
<div class="form-group margin_top">
<label for="street_1" class="required col-md-4 control-label"><?php echo $this->__('Adresse') ?><em>* :</em></label>
<div class="col-md-6">
<div class="row">
<div class="col-md-3 nopaddingright">
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text form-control <?php echo $_streetValidationClass ?>" />
</div>
<div class="col-md-9 address_block">
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="form-control input-text <?php echo $_streetValidationClass ?>" />
<?php endfor; ?>
</div>
<div class="col-md-9 nopaddingright">
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="form-control input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
</div>
<div class="col-md-3 address_block">
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text form-control validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
</div>
<div class="col-md-12">
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text form-control <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" />
</div>
</div>
</div>
2 . i also need mobile(cell) field to be added into my form how can i add that and save into my
database.
do i need to create Custom module ? please suggest me and help me
Thank you
I need to change the email validation of Magento's Checkout page (Checkout as a Guest).
The problem is the default style of input box contains character support only. When I tried to input email with numbers, it doesn't accept and display number.
So I need a proper validation with regard to its email. The email address input box should also accept characters with numbers.
Thanks,
I tried to check this Code:
File location: onepage/billing.phtml
<?php if(!$this->isCustomerLoggedIn()): ?>
<div class="field">
<label for="billing:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
<div class="input-box">
<input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
</div>
</div>
<?php endif; ?>
File location: validation.js
['validate-email', 'Please enter a valid email address. For example johndoe#domain.com.', function (v) {
//return Validation.get('IsEmpty').test(v) || /\w{1,}[#][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
//return Validation.get('IsEmpty').test(v) || /^[\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9][\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9\.]{1,30}[\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9]#([a-z0-9_-]{1,30}\.){1,5}[a-z]{2,4}$/i.test(v)
return Validation.get('IsEmpty').test(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*#([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v)
}],
I found the solution.
File Location: template/webtexgiftregisrty/billing.phtml
On th field box of email address, insert the string data types inside the class validation.
Here's the code:
<input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="string input-block-level input-text validate-email required-entry billing-email" />
How to make middle name required in magento customer entity?
There is option in System->Configuration->Customer configuration, but it's optional.
To make your Middle Name field Required open the following file:
/app/design/frontend/default/[YOURTHEME]/template/customer/widget/name.phtml
or if it doesn't exist there, open:
/app/design/frontend/base/default/template/customer/widget/name.phtml
Look for the following code:
<input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->htmlEscape($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->getStoreLabel('middlename') ?>" class="input-text" <?php echo $this->getFieldParams() ?> />
Where it says class="input-text" make it say class="input-text required-entry"
<input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->htmlEscape($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->getStoreLabel('middlename') ?>" class="input-text required-entry" <?php echo $this->getFieldParams() ?> />
It's toward the end of the line. Look at the other code in the file as well-- they all have the same class.
I have an order form with data. on submit the controller function new_blank_order_summary is called.
the syntax for this is:
function new_blank_order_summary()
{
echo "orderlines: ".$this->input->post(orderlines);
echo "customer: ".$this->input->post('customer');
echo "period: ".$this->input->post('period');
echo "creditlimit: ".$this->input->post('creditlimit');
$this->load->view('sales/new_blank_order_summary');
}
I cannot get the post information to display or echo? my input Name and ID is orderlines but this is not being posted or received properly.
Apologies for the 'stupid' question.
any advice welcome.
HTML
<form id="sales_blank_order_details" action="/sales/new_blank_order_summary" method="post">
<table >
<tr><td>Customer</td><td>Period</td><td>UoM</td><td>Credit Limit</td><td>Balance</td><td>New Balance</td><td>Order Lines</td><td>Round to Bundle</td></tr>
<tr><td>
<input type="text" name="customer" id="customer" value="<?php echo $customer; ?>" disabled>
</td><td>
<input type="text" name="period" id="period" value="<?php echo $period." to ".$newperiod; ?>" disabled>
</td><td>
<input type="text" name="buom" id="buom" value="<?php echo $buom; ?>" disabled>
</td><td>
<input type="text" name="creditlimit" id="creditlimit" value="<?php echo $creditlimit['creditlimit']; ?>" disabled>
</td><td>
<input type="text" name="currentbalance" id="currentbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled>
</td>
<td>
<input type="text" name="newbalance" id="newbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled>
</td><td>
<input type="text" name="orderlines" id="orderlines" value="1" disabled>
</td><td>
<input type="checkbox" name="rounduptobundle" id="rounduptobundle" checked>
</td></tr></table>
<input type="submit" name="blank_order_lines" id="blank_order_lines" value="Save Order and Proceed">
</form>
None of these posts are outputted by controller.
You've disabled the orderlines text input field so that's why it will not get posted. Remove disabledand it will show up in $this->input->post().
what is the name and value of your submit button. Usually the name of my submit button is name="submit" and the value is value="submit". So then I try $this->input->post('submit')=='submit'. try this in your if condition. I hope it will work. best of luck.
function new_blank_order_summary()
{
echo "orlderlines: ".$this->input->post('orderlines');
echo "customer: ".$this->input->post('customer');
echo "period: ".$this->input->post('period');
echo "creditlimit: ".$this->input->post('creditlimit');
$this->load->view('sales/new_blank_order_summary');
}
Please try this code. I didn't change a single line in it. Only I put the single quotes in the 3rd line. And, changed it's variable name is wrong so I changed it