close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Date reformat in coupon, product insert

Thread began 11/21/2010 11:48 pm by Russell Collins | Last modified 3/23/2011 4:52 pm by Jason Byrnes | 3239 views | 12 replies |

Russell CollinsBeta Tester

Date reformat in coupon, product insert

Hi,

I my quest to ozzify PS4 can I change the date format display on the insert page of coupons and products insert.

The code below is the coupon insert start date. line 175

<input id="CouponStartDate" name="CouponStartDate" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("couponsInsert","CouponStartDate"):"")); ?>" class="formTextfield_Medium" tabindex="7" onblur="hideServerError('CouponStartDate_ServerError'); return false;"/>

Regards

Russ

Sign in to reply to this post

Russell CollinsBeta Tester

ps, it displays as mm,dd,YY
I would like the display as dd,mm,YY

Sign in to reply to this post

Jason ByrnesWebAssist

in the admin/scripts/coupons_insert.js file


change:

$(function(){
$('#CouponStartDate').datepicker({
changeMonth: true,
changeYear: true,
onClose: closeDatePicker_CouponStartDate
});
});



to:

$(function(){
$('#CouponStartDate').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy',
onClose: closeDatePicker_CouponStartDate
});
});




and change:

$(function(){
$('#CouponEndDate').datepicker({
changeMonth: true,
changeYear: true,
onClose: closeDatePicker_CouponEndDate
});
});



to:

$(function(){
$('#CouponEndDate').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy',
onClose: closeDatePicker_CouponEndDate
});
});




on the coupon_insert.php page you will also need to change:

var CouponStartDate_Spry = new Spry.Widget.ValidationTextField("CouponStartDate_Spry", "date", {format:"mm/dd/yyyy", validateOn:["blur"]});
var CouponEndDate_Spry = new Spry.Widget.ValidationTextField("CouponEndDate_Spry", "date", { format:'mm/dd/yyyy' , validateOn:["blur"]});




to:

var CouponStartDate_Spry = new Spry.Widget.ValidationTextField("CouponStartDate_Spry", "date", {format:"dd/mm/yyyy", validateOn:["blur"]});
var CouponEndDate_Spry = new Spry.Widget.ValidationTextField("CouponEndDate_Spry", "date", { format:'dd/mm/yyyy' , validateOn:["blur"]});
Sign in to reply to this post

jebrandon343719

Sames issue with users_Search

Hi, In PS3, I wish to do the same in the users_Search file. I wish to enter dd/mm/yyyy
How is this achieved. Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

I'm not sure i understand, the PS3 users search page already allows you to enter the date in that format and will automatically convert it to the format needed by the database.

Sign in to reply to this post

jebrandon343719

I cannot get this to work

Hi Jason,
Maybe I have done something wrong...it is not working for me. The Spry format was originally yyyy-mm-dd. I changed this to dd/mm/yyyy
Then I enter 10/03/2011 (10th March). On blur the field gets converted to 03-10-2011 and I get the error 'invalid format'

Sign in to reply to this post

Jason ByrnesWebAssist

dont change the spry validation, you should change the client validation to aloow for your date format.


change:

php:
<input class="dateRange" name="S_UserRegistrationDate" type="text" id="S_UserRegistrationDate" onblur="if (document.getElementById('S_UserRegistrationDateServerValidation')) document.getElementById('S_UserRegistrationDateServerValidation').style.display='none';WAValidateDT(document.forms[0].S_UserRegistrationDate,'- Invalid date or time',true,/.*/,'yyyy-mm-dd','','',false,/.*/,'','','',document.forms[0].S_UserRegistrationDate,0,true)" value="<?php echo((isset($_GET["S_UserRegistrationDate"]))?$_GET["S_UserRegistrationDate"]:""?>" size="15" />

          </span> to <span id="sprytextfield3">
            <input class="dateRange" type="text" name="S_UserRegistrationDate2" id="S_UserRegistrationDate2" value="<?php echo((isset($_GET["S_UserRegistrationDate2"]))?$_GET["S_UserRegistrationDate2"]:""?>" onblur="if (document.getElementById('S_UserRegistrationDateServerValidation')) document.getElementById('S_UserRegistrationDateServerValidation').style.display='none';WAValidateDT(document.forms[0].S_UserRegistrationDate2,'- Invalid date or time',true,/.*/,'yyyy-mm-dd','','',false,/.*/,'','','',document.forms[0].S_UserRegistrationDate2,0,true)" size="15" />



to:

php:
<input class="dateRange" name="S_UserRegistrationDate" type="text" id="S_UserRegistrationDate" onblur="if (document.getElementById('S_UserRegistrationDateServerValidation')) document.getElementById('S_UserRegistrationDateServerValidation').style.display='none';WAValidateDT(document.forms[0].S_UserRegistrationDate,'- Invalid date or time',true,/\b([12]\d|3[0-1]|0?[1-9])\/(1[0-2]|0?[1-9])\/\d{4}\b/,'yyyy-mm-dd','','',false,/.*/,'','','',document.forms[0].S_UserRegistrationDate,0,true)" value="<?php echo((isset($_GET["S_UserRegistrationDate"]))?$_GET["S_UserRegistrationDate"]:""?>" size="15" />

          </span> to <span id="sprytextfield3">
            <input class="dateRange" type="text" name="S_UserRegistrationDate2" id="S_UserRegistrationDate2" value="<?php echo((isset($_GET["S_UserRegistrationDate2"]))?$_GET["S_UserRegistrationDate2"]:""?>" onblur="if (document.getElementById('S_UserRegistrationDateServerValidation')) document.getElementById('S_UserRegistrationDateServerValidation').style.display='none';WAValidateDT(document.forms[0].S_UserRegistrationDate2,'- Invalid date or time',true,/\b([12]\d|3[0-1]|0?[1-9])\/(1[0-2]|0?[1-9])\/\d{4}\b/,'yyyy-mm-dd','','',false,/.*/,'','','',document.forms[0].S_UserRegistrationDate2,0,true)" size="15" />
Sign in to reply to this post

jebrandon343719

Still has errors

I changed the code, but still get an error on submit. I entered 10/03/2011 in both fields - see attached

Sign in to reply to this post

Jason ByrnesWebAssist

you need to change the pry validation back to the original code and only make changes to the client validation.

Sign in to reply to this post

jebrandon343719

Strange

Hi Jason, I had already done that. The spry format is yyyy-mm-dd
I modified by using your code above.
I enter 10/03/2011 - the server code (on blur) converts this to 2011-03-10
On submit I get the error below. It occurs even if I leave the 2nd field blank.
This is my code
<label for="S_UserRegistrationDate">Registration Date:</label>
<span id="sprytextfield2">
<span id="sprytextfield2">
<input class="dateRange" name="S_UserRegistrationDate" type="text" id="S_UserRegistrationDate" onblur="if (document.getElementById('S_UserRegistrationDateServerValidation')) document.getElementById('S_UserRegistrationDateServerValidation').style.display='none';WAValidateDT(document.forms[0].S_UserRegistrationDate,'- Invalid date or time',true,/\b([12]\d|3[0-1]|0?[1-9])\/(1[0-2]|0?[1-9])\/\d{4}\b/,'yyyy-mm-dd','','',false,/.*/,'','','',document.forms[0].S_UserRegistrationDate,0,true)" value="<?php echo((isset($_GET["S_UserRegistrationDate"]))?$_GET["S_UserRegistrationDate"]:"") ?>" size="15" />
</span> to <span id="sprytextfield3">
<input class="dateRange" type="text" name="S_UserRegistrationDate2" id="S_UserRegistrationDate2" value="<?php echo((isset($_GET["S_UserRegistrationDate2"]))?$_GET["S_UserRegistrationDate2"]:"") ?>" onblur="if (document.getElementById('S_UserRegistrationDateServerValidation')) document.getElementById('S_UserRegistrationDateServerValidation').style.display='none';WAValidateDT(document.forms[0].S_UserRegistrationDate2,'- Invalid date or time',true,/\b([12]\d|3[0-1]|0?[1-9])\/(1[0-2]|0?[1-9])\/\d{4}\b/,'yyyy-mm-dd','','',false,/.*/,'','','',document.forms[0].S_UserRegistrationDate2,0,true)" size="15" />
<span class="textfieldInvalidFormatMsg">Invalid format.</span></span><span id="additionalErrorZone" class="additionalErrorZone"><span class="textfieldRequiredMsg textfieldInvalidFormatMsg textfieldMinCharsMsg textfieldMaxCharsMsg textfieldMinValueMsg textfieldMaxValueMsg">Please enter a valid date, or leave these fields blank.</span></span>
<?php
if (ValidatedField("usersResults","usersResults")) {
if ((strpos((",".ValidatedField("usersResults","usersResults").","), "," . "2" . ",") !== false || "2" == "") || (strpos((",".ValidatedField("usersResults","usersResults").","), "," . "3" . ",") !== false || "3" == "")) {
if (!(false)) {
?>
<span class="textfieldServerError" id="S_UserRegistrationDateServerValidation">Please enter a valid date, or leave these fields blank.</span>
<?php //WAFV_Conditional users_Results.php usersResults(2,3:)
}
}
}?>

This is the Spry:
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer", {validateOn:["blur"], isRequired:false});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "date", {format:"yyyy/mm/dd", isRequired:false, additionalError:"additionalErrorZone"});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "date", {format:"yyyy/mm/dd", isRequired:false, additionalError:"additionalErrorZone"});

Thanks

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...