can I get help on DOB validation on magento - php

I am new in magento I would to validate my DOB fileds on the registratoin page so that valid dates can be inserted by the user, at the moment the input fieds accept anything and a user can input any number of text and it accepts can you guys please help?

Look in your theme's (or default) template/customer/form/widget/dob.phtml file. It creates three strings which describe the three text inputs for day, month and year. You can either add the validate-number name to their class or rewrite them to use <select> elements instead.

Related

How to change the color of a row based on the value of a specific field?

I've been using Drupal 7.42 to implement an inventory library. I have so far created a table view containing fields of a custom content type. The result is pretty similar to the one shown in the picture.
table view
I am wondering if there is a way for me as shown to color the rows based for example on a field which indicates the return date of an object. When this date expires the row should turn to red.
Thanks in advance
You can follow this:
1) give css-class to that column. so, in each row that column will come with that css class.
2) Include Jquery.
3) In document.ready({}): check for that column's each value and check if the date is expired or not and if the date is expired then you can remove existing class and add new class using jquery.
You can provide your html code to me.

D7, Views 3 | How do you conditionally rewrite fields?

In Views, when I rewrite a field and then hide some other fields and use their tokens to compile them into that first one I rewrite, how would I go about doing an operation such as this:
Example:
Say I have these fields:
field_first_name
field_last_name
field_old_nickname
field_new_nickname
Everyone has a first & last name, but:
Some people have ONLY an old nickname
Some people have ONLY a new nickname
Some people have both an old & new nickname
What if I want to rewrite these fields into a format such as "John (Nobody) Doe?"
Normally, we would hide all fields but the first name and do this:
[field_first_name] ([field_new_nickname]) [field_last_name]
But what if John has a old nickname too and we want to display the old one instead if that's the case?
Get what I'm saying?
Thanks in advance.
You can use the option "exclude from display if empty" for the
two fields "field_new_nickname" and "field_old_nickname"
then rewrite the output field as : [field_first_name]
([field_new_nickname] ,[field_old_nickname]) [field_last_name]
so the empty field will not show up
A #drupal-support IRC user named "ciss" answered this question for me-- it was much easier than I had thought, which is great. Thank you ciss!:
"Regarding your tokens question: you can use tokens in the empty output of a field. That way you can trigger which tokens should get displayed. Make sure you pick a field for rewriting that can actually be empty (either empty string or "0"). if necessary, add a specific field twice-- Views will not check if the rewritten content is empty."

php shortcode function to add other sum other shortcode values

im doing some web designing with wordpress at the moment.
I have created a page with a web form where a client can input some information (name, email, invoice number, price, gst, etc).
I used a plugin called contact form 7 to provide the web form, when the user inputs all of their information, the plugin then emails an html formatted invoice to my email address, with the fields occupied by shortcodes which take on the value from the web form.
For example, in the name field of my invoice table, i enter [first-name] and the name the user inputs gets emailed to me in the invoice.
I need to find a way to sum the value of two of the other fields, one of the fields on my invoice form is called total, which should be equal to [gst]+[price] that the user inputs on the web form.
Ive tried to look for a php shortcode function that can take its arguments as the values of other shortcodes, but havent had any luck. I have never really used php before either so wouldnt know how to write one.
I managed to find this, which doesnt seem to work, as when the email comes through all i see is [sumsc][gst] [price][/sumsc]
add_shortcode('sumsc','sumsc_func');
function sumsc_func( $atts, $content = null ) {
$sum=0;
$content=str_replace(array(" ","] [","]["),array(" ","][","]|["),$content);
$codes=explode("|",$content);
foreach($codes as $code){
$sum+=do_shortcode($code);
}
return " <div>".$sum."
</div>";
}
Any help would be greatly appreciated, I also need to the functionality to be able to multiply a shortcode value by a certain number. For example the price needs to be divided by 0.6 to give the quantity which appears on the invoice. Thanks!
Create a hidden field in the form say with a unique id say it fields_sum.
Use jquery on that page and catch form submission event. Get values of those fields, sum it and set the result to fields_sum field. And then use field shortcode where you want.
jQuery script would be something like (Algorithm)
$(document).ready(function(){
$("your_form_id").submit(function(e){
// get value of field one
// get value of field two
// sum them
// set sum to the hidden field
});
});
I hope this works and enough to get a solution like this.

Force refresh data before posting to database

The problem is :
There are two pages , one for editing name records and one for adding name records.
If I first open an edit page,then I open an add page , and input a name in add page
before I submit the name, I use the edit page to change the name,
(say change from varChar to integer type)
,after that, return to add page and submit the name.
Should this cause an error? How can I prevent this error?
In most web applications that I have used, the first valid request to be processed wins. I think you need to clarify your question, though, as it doesn't sound like the situation you describe would be possible, or it would not be a problem.
It sounds like NAME is a field in a record, not an entire record on its own. It doesn't seem like you could change the NAME field and add it at the same time. Let's imagine you have a record type PERSON that is backed by a table in your database. Each PERSON record has a NAME field that is currently of varChar type. It sounds like you are using a web interface to edit the structure of this table.
If the table already has a field NAME, the add page submission will report an error because a field called NAME already exists. The edit page would succeed, assuming it is possible to convert the NAME field to the integer type: either there are no records, or the value of NAME in every record can be converted to an integer.
Another interpretation of your question is that you are changing the NAME field to be something else entirely in the edit screen, perhaps from NAME varChar to AGE integer. You also happen to use the add page to add a new NAME char(10), for example. This would be allowed as long as the edit page submission is processed before the add page submission.

How to handle $_POST results of autosuggest multi-input on form

I have the following JsFiddle to help with my question:
http://jsfiddle.net/eY2yH/3/
I am ultimately trying to create a simple input field which allows a user to enter multiple 'names' which creates a message to those users on our system. In many ways, this should function EXACTLY as Composing an email in Gmail (enter text for a user name/email, the autosuggests appears, then allow for additional input or submit).
When I run the code given, the results of the $_POST are quite strange.
Depending on which members are selected, the value of the key changes:
array([as-results-0XXX]=>1,2,3,4)
where XXX varies and 1,2,3,4 would represent the value of the members selected. These values are stored in a single element and separated by comma. In the end, I want to run through a loop for each user selected and send the necessary alert:
If 3 members are selected, e.g.
foreach($rows as $row) {
do table insert with particular value
}
My site is built with php and clearly using jquery. I have done a bit of searching and can find nothing regarding multiple inputs on the same autosuggest field.
You can change the way the name of the hidden input is determined by adding the asHtmlID attribute to your .autoSuggest():
$("input.autoSuggest").autoSuggest(data.items, {
selectedItemProp: "name",
searchObjProps: "name",
asHtmlID: "custom_id"
});
The variable posted to your php script will be available through $_POST['as_values_custom_id']

Categories