Thursday, November 27, 2014

jQuery disable paste on a form field

In the case of a form where the user is asked to re-enter a field to ensure accuracy, it is a good idea to disable paste functionality on the second field. This is to ensure the user does not enter the data incorrectly then copy/paste it into the second field.

The following jQuery will achieve this.
$(document).ready(function () {
    $('#email').bind("paste", function (e) {

Monday, November 24, 2014

JavaScript RegEx to check for strong password

The following code will match RegEx against a password to check if it meets strong password complexity requirements (Passwords must be at least eight characters including at least one number and one special character (punctuation, symbol or upper/lower case character).
var password = "Mypassword01";
var regexString = "^((?=.{8,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*|(?=.{8,}$)(?=.*\d)(?=.*[a-zA-Z])(?=.*[!\u0022#$%&'()*+,./:;⇔?@[\]\^_`{|}~-]).*)";
var regexx = new RegExp(regexString);

if (!regexx.test(password)) {
  // password did not match regex

Tuesday, November 18, 2014

Error creating the Web Proxy specified in the configuration section.

I came across the following error when calling a WCF service:
Error creating the Web Proxy specified in the '' configuration section.
This error was being generated because the project was stored on a network drive. After moving the project to local disk it called the service correctly and no error was generated.

Monday, November 17, 2014

Referencing a TIBCO WSDL service in .NET

When adding a TIBCO WCF service to a .NET project (via 'Add Web Reference'), the service may not be discovered correctly and the following error is encountered: "The HTML document does not contain Web service discovery information.".

The solution to this issue is to take the WSDL generated by TIBCO and place it in the local file system, this can then be used to add the WSDL (and it will be picked up correctly).

The URL to the service could then be changed inside web.config/app.config or at runtime.

Sitecore items missing from web database

An error occurs when not logged into sitecore and browsing the web site (so web database is being used) and the site won't load due to missing items (such as layout or template). The content editor may also not load when web database is selected.

In this case the error was traced back to the "Sitecore/Templates/System/Layout" folder not having a version, which meant that the entire folder and it's contents never got published to the web database (potentially only the original publish of this folder was available in web). Therefore if an item is missing in the web database but appears in the master database, check that a version exists - and if it doesn't create one and try publishing again.

This then caused the web database to be out of sync and there were problems browsing the site/accessing content editor (when web database is selected).