Hi,
I have to insert a js function to a field form like this
<tr><td>sunday:</td><td><input type="text" name="sunday" size="4" id="sunday" onblur="checkmin()"></td></tr>
The question is:
in the designer tab I inserted a text field named sunday. Now I have insert a js function custom connected with this field. I found out a place in Validation tab called Custom function.
I wrote checkmin() inside but hoiw can specify onblur?
Thanks
I have to insert a js function to a field form like this
<tr><td>sunday:</td><td><input type="text" name="sunday" size="4" id="sunday" onblur="checkmin()"></td></tr>
The question is:
in the designer tab I inserted a text field named sunday. Now I have insert a js function custom connected with this field. I found out a place in Validation tab called Custom function.
I wrote checkmin() inside but hoiw can specify onblur?
Thanks
Hi kiwiup,
I would do it with this code in a Load JS action:
Are you sure that onBlur is the best event for this?
Bob
I would do it with this code in a Load JS action:
jQuery(document).ready(function(jQ){
jQ('#Sunday').blur(checkmin);
});
Are you sure that onBlur is the best event for this?
Bob
Hi Bob,
my task is to achieve a check on sum of numeric fields before submit a form.
Example:
field weekhour = 30
field mondayhour=2
...
field saturdayhour=2
field sundayhour=6
If (weekhour != mondayhour + tuesdayhour +......+ sundayhour)
then waring message
sundayhour is the last field inserted so when I leave it start js validation.
I will try your hint.
Thanks
Kiwiup
my task is to achieve a check on sum of numeric fields before submit a form.
Example:
field weekhour = 30
field mondayhour=2
...
field saturdayhour=2
field sundayhour=6
If (weekhour != mondayhour + tuesdayhour +......+ sundayhour)
then waring message
sundayhour is the last field inserted so when I leave it start js validation.
I will try your hint.
Thanks
Kiwiup
Hi Kiwiup,
Why not just make the weekhour readonly and calculate the total as the user enters the day. Or, if you want it as a check have a second weekhour_check and compare the two. I think you could then use the built-in Confirm validation check to make sure that they are the same.
Bob
Why not just make the weekhour readonly and calculate the total as the user enters the day. Or, if you want it as a check have a second weekhour_check and compare the two. I think you could then use the built-in Confirm validation check to make sure that they are the same.
Bob
Hi Bob,
the user inserts all values also weekhour.
I made the js function to get this check and it works. I would like to know how can properly insert this function on CF5.
I have 8 fields from weekhour to sundayhour.
How can get the sym of hour from monday to sunday, save this sun in a hidden field called weekhour_check to compare with weekhour?
Thanks.
Kiwiup.
the user inserts all values also weekhour.
I made the js function to get this check and it works. I would like to know how can properly insert this function on CF5.
I have 8 fields from weekhour to sundayhour.
How can get the sym of hour from monday to sunday, save this sun in a hidden field called weekhour_check to compare with weekhour?
Thanks.
Kiwiup.
Hi KiwiUp,
You'll have a JavaScript function something like this:
Bob
You'll have a JavaScript function something like this:
jQuery(document).ready(function(jQ){
jQ('#Monday').keyup(checkmin);
jQ('#Sunday').keyup(checkmin);
function checkmin() {
var mon., tue, wed, . . .sun. weekehour ;
mon = parseInt(jQ('#Monday'),val());
. . .
sun = parseInt(jQ('#Sunday'),val());
total = parseInt(mon) + . . . + parseInt(sun);
jQ('#weekhour_check').val(total);
// something here to compare the two ??
weekhour = jQ('#weekhour_check').val();
if ( total != parseInt(weekhour) ) {
// do something
}
}
});
Bob
Hi Bob,
I made a form with 8 fields:
1 for monday
2 for tuesday
3 for wednesday
4 for thursday
5 for friday
6 for saturday
7 for sunday
8 for weekhour
I inserted a button to check if the sum from mon to sun is equal to weekhour.
Can you help me?
Thanks
Kiwiup
I made a form with 8 fields:
1 for monday
2 for tuesday
3 for wednesday
4 for thursday
5 for friday
6 for saturday
7 for sunday
8 for weekhour
I inserted a button to check if the sum from mon to sun is equal to weekhour.
Can you help me?
Thanks
Kiwiup
jQuery(document).ready(function(jQ){
jQ('#Monday').keyup(checkmin);
jQ('#Tuesday').keyup(checkmin);
jQ('#Wednesday').keyup(checkmin);
jQ('#Thursday').keyup(checkmin);
jQ('#Friday').keyup(checkmin);
jQ('#Saturday').keyup(checkmin);
jQ('#Sunday').keyup(checkmin);
function checkmin() {
var mon., tue, wed,thu,fri,sat,sun,weekehour ;
mon = parseInt(jQ('#Monday'),val());
tue = parseInt(jQ('#Tuesday'),val());
wed = parseInt(jQ('#Wednesday'),val());
thu = parseInt(jQ('#Thursday'),val());
fri = parseInt(jQ('#Friday'),val());
sat = parseInt(jQ('#Saturday'),val());
sun = parseInt(jQ('#Sunday'),val());
total = parseInt(mon) + parseInt(tue) +parseInt(wed) +parseInt(thu) + parseInt(fri)+ parseInt(sat)+ parseInt(sun);
jQ('#weekhour_check').val(total);
aler('Warning the total is different by weekehour ')
weekhour = jQ('#weekhour_check').val();
if ( total != parseInt(weekhour) ) {
// do something
}
}
});
Hi Kiwiup,
What is the button for? - the code I sketched out is set up to run automatically every time one of the inputs changes.
What isn't working?
Bob
What is the button for? - the code I sketched out is set up to run automatically every time one of the inputs changes.
What isn't working?
Bob
Hi Bob,
I inserted hte js code above in the On Load form before HTML Render form.
But after inserting a value in a field day (mon, tue ...sun) nothing happen.
Maybe I am making something wrong.
To resume:
I made a form with simple text felds (8)from mon to sun and weekhou).
I inserted a js code above in On Load before HTML Render form.
I will get that when I insert a value in a day starts a function checkmin to calculate the total againts weekhour showing a alert message if these fields are different.
I have to do something else?
Thanks
I inserted hte js code above in the On Load form before HTML Render form.
But after inserting a value in a field day (mon, tue ...sun) nothing happen.
Maybe I am making something wrong.
To resume:
I made a form with simple text felds (8)from mon to sun and weekhou).
I inserted a js code above in On Load before HTML Render form.
I will get that when I insert a value in a day starts a function checkmin to calculate the total againts weekhour showing a alert message if these fields are different.
I have to do something else?
Thanks
Hi Bob,
this is my form
http://www.fabiocenci.it/bd/index.php?option=com_chronoforms5&chronoform=exampleweekday
Thanks
Kiwiup
this is my form
http://www.fabiocenci.it/bd/index.php?option=com_chronoforms5&chronoform=exampleweekday
Thanks
Kiwiup
This topic is locked and no more replies can be posted.
