alpha versione complete
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/accept-invite-portlet@160094 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d5aedc3c63
commit
4bf9153c45
|
@ -14,14 +14,16 @@
|
|||
|
||||
package org.gcube.portlets.user.acceptinvite;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.portlet.ResourceRequest;
|
||||
import javax.portlet.ResourceResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
|
@ -38,28 +40,28 @@ import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.portlet.bind.annotation.ActionMapping;
|
||||
import org.springframework.web.portlet.bind.annotation.RenderMapping;
|
||||
import org.springframework.web.portlet.bind.annotation.ResourceMapping;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.json.JSONArray;
|
||||
import com.liferay.portal.kernel.json.JSONFactoryUtil;
|
||||
import com.liferay.portal.kernel.json.JSONObject;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.kernel.util.ParamUtil;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.service.ServiceContext;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
|
||||
@Controller(value = "PortletViewController")
|
||||
@RequestMapping("VIEW")
|
||||
public class PortletViewController {
|
||||
private static Log _log = LogFactoryUtil.getLog(PortletViewController.class);
|
||||
public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
|
||||
Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
public static final String DEFAULT_COMPANY_WEB_ID = "liferay.com";
|
||||
|
||||
private static String PAGE_NOT_AUTHORIZED = "not-authorized";
|
||||
private static String PAGE_INVITE_NOTFOUND = "invite-notfound";
|
||||
|
@ -69,6 +71,8 @@ public class PortletViewController {
|
|||
|
||||
public static String INVITE_INSTANCE = "inviteInstance";
|
||||
|
||||
private static String MODEL_ATTR = "theModel";
|
||||
|
||||
private static DatabookStore store;
|
||||
|
||||
/**
|
||||
|
@ -135,44 +139,122 @@ public class PortletViewController {
|
|||
model.addAttribute("groupId", site.getGroupId());
|
||||
model.addAttribute("landingPage", PortalContext.getConfiguration().getSiteLandingPagePath(httpReq));
|
||||
|
||||
HttpSession session = httpReq.getSession();
|
||||
session.setAttribute(MODEL_ATTR, model);
|
||||
|
||||
return PAGE_INVITE_PROCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ResourceMapping(value="findState")
|
||||
public void findStateForCountry(ResourceRequest request, ResourceResponse response) throws IOException {
|
||||
String countryName = ParamUtil.getString(request, "countryName");
|
||||
_log.info("countryName=" + countryName);
|
||||
JSONArray stateArray = JSONFactoryUtil.createJSONArray();
|
||||
JSONObject stateObject,stateObject2;
|
||||
if(countryName.equalsIgnoreCase("india"))
|
||||
{
|
||||
stateObject = JSONFactoryUtil.createJSONObject();
|
||||
stateObject.put("stateId", "1");
|
||||
stateObject.put("name", "Delhi");
|
||||
|
||||
stateObject2 = JSONFactoryUtil.createJSONObject();
|
||||
stateObject2.put("stateId", "2");
|
||||
stateObject2.put("name", "Gujrat");
|
||||
@ResourceMapping(value="createAccount")
|
||||
public void createAccountForUser(ResourceRequest request, ResourceResponse response) throws IOException {
|
||||
String email = ParamUtil.getString(request, "email");
|
||||
String firstName = ParamUtil.getString(request, "firstname");
|
||||
String lastName = ParamUtil.getString(request, "lastname");
|
||||
String password = ParamUtil.getString(request, "password");
|
||||
String repassword = ParamUtil.getString(request, "repassword");
|
||||
_log.info("firstName=" + firstName);
|
||||
_log.info("lastName=" + lastName);
|
||||
_log.info("email=" + email);
|
||||
_log.info("password=" + password);
|
||||
_log.info("repassword=" + repassword);
|
||||
|
||||
|
||||
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request));
|
||||
Model model = (Model) httpReq.getSession().getAttribute(MODEL_ATTR);
|
||||
Invite invite = (Invite) model.asMap().get(INVITE_INSTANCE);
|
||||
|
||||
if (invite.getInvitedEmail().compareTo(email) != 0) {
|
||||
response.getWriter().println("The email address invited does not match or is empty.");
|
||||
return;
|
||||
}
|
||||
else{
|
||||
|
||||
stateObject = JSONFactoryUtil.createJSONObject();
|
||||
stateObject.put("stateId", "21");
|
||||
stateObject.put("name", "LA");
|
||||
|
||||
stateObject2 = JSONFactoryUtil.createJSONObject();
|
||||
stateObject2.put("stateId", "22");
|
||||
stateObject2.put("name", "California");
|
||||
//check the fields before creating account
|
||||
if (firstName == null
|
||||
|| firstName.equals("")
|
||||
|| lastName == null
|
||||
|| lastName.equals("")
|
||||
|| email.equals("")
|
||||
|| password.equals("")
|
||||
|| repassword.equals("")
|
||||
|| password.length() < 8) {
|
||||
response.getWriter().println("Not all the required fields have been filled.");
|
||||
return;
|
||||
}
|
||||
stateArray.put(stateObject);
|
||||
stateArray.put(stateObject2);
|
||||
response.getWriter().println(stateArray);
|
||||
if (!validate(email)) {
|
||||
response.getWriter().println("The email address invited does not look like a valid email address.");
|
||||
return;
|
||||
}
|
||||
|
||||
//checking if the user has been already registered or is already in the portal
|
||||
GCubeUser theUser = register(firstName, lastName, email, password);
|
||||
if (theUser != null)
|
||||
response.getWriter().println("OK");
|
||||
else
|
||||
response.getWriter().println("Something went wrong when creating your account during server communication, please check your connection.");
|
||||
return;
|
||||
}
|
||||
|
||||
private static boolean validate(String emailStr) {
|
||||
Matcher matcher = VALID_EMAIL_ADDRESS_REGEX .matcher(emailStr);
|
||||
return matcher.find();
|
||||
}
|
||||
|
||||
}
|
||||
private GCubeUser register(String firstName, String lastName, String email, String password1) {
|
||||
GCubeUser toReturn = null;
|
||||
try{
|
||||
_log.debug("Trying createuser " + email);
|
||||
Long defaultCompanyId = PortalUtil.getDefaultCompanyId();
|
||||
Long defaultUserId = UserLocalServiceUtil.getDefaultUserId(defaultCompanyId);
|
||||
|
||||
boolean autoPassword = false;
|
||||
Locale locale = new Locale("en_US");
|
||||
int prefixId = 0;
|
||||
int suffixId = 0;
|
||||
int birthdayMonth = 1;
|
||||
int birthdayDay = 1;
|
||||
int birthdayYear = 1970;
|
||||
String password2 = password1;
|
||||
User added = UserLocalServiceUtil.addUser(
|
||||
defaultUserId,
|
||||
defaultCompanyId,
|
||||
autoPassword,
|
||||
password1,
|
||||
password2,
|
||||
true,
|
||||
"",
|
||||
email,
|
||||
0L,
|
||||
"",
|
||||
locale,
|
||||
firstName,
|
||||
"",
|
||||
lastName,
|
||||
prefixId,
|
||||
suffixId,
|
||||
true,
|
||||
birthdayMonth,
|
||||
birthdayDay,
|
||||
birthdayYear,
|
||||
"",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
new ServiceContext());
|
||||
_log.debug("CreateUser " + lastName + " SUCCESS");
|
||||
UserLocalServiceUtil.updateAgreedToTermsOfUse(added.getUserId(), false);
|
||||
UserLocalServiceUtil.updatePasswordReset(added.getUserId(), false);
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
// unable to create.. we need to delete it from the list of users
|
||||
_log.error("Unable to create the user " + email + " in liferay.", e);
|
||||
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,173 +10,135 @@
|
|||
<portlet:defineObjects />
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
|
||||
<portlet:resourceURL id="findState" var="findState"></portlet:resourceURL>
|
||||
<portlet:resourceURL id="createAccount" var="createAccount"></portlet:resourceURL>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
||||
$( "#createAccountButton" ).click(function() {
|
||||
var firstnameBox = $.trim( $('#firstname').val() )
|
||||
if (firstnameBox == "") {
|
||||
$('#labelFirstName').css("color","red");
|
||||
$('#labelFirstName').text("First Name (This field is required)");
|
||||
} else {
|
||||
$('#labelFirstName').css("color","#555");
|
||||
$('#labelFirstName').text("First Name (Required)");
|
||||
}
|
||||
var lastnameBox = $.trim( $('#lastname').val() )
|
||||
if (lastnameBox == "") {
|
||||
$('#labelLastName').css("color","red");
|
||||
$('#labelLastName').text("Last Name (This field is required)");
|
||||
} else {
|
||||
$('#labelLastName').css("color","#555");
|
||||
$('#labelLastName').text("Last Name (Required)");
|
||||
}
|
||||
|
||||
var passwd1 = $('#password');
|
||||
var labelPwd1 = $('#labelPwd1');
|
||||
var passwd2 = $('#repassword');
|
||||
var labelPwd2 = $('#labelPwd2');
|
||||
|
||||
labelPwd1.addClass( passwd1.val().length === 0 ? 'has-error' : 'has-success' );
|
||||
labelPwd2.addClass( passwd2.val().length === 0 ? 'has-error' : 'has-success' );
|
||||
|
||||
var nomatch = $('#labelPasswordDontMatch');
|
||||
|
||||
if (passwd1.val() !== passwd2.val()) {
|
||||
nomatch.css("display","block");
|
||||
nomatch.css("color","red");
|
||||
labelPwd1.addClass( passwd1.val() !== passwd2.val() ? 'has-error' : 'has-success' )
|
||||
.removeClass( passwd1.val() === passwd2.val() ? 'has-error' : 'has-success' );
|
||||
labelPwd2.addClass( passwd1.val() !== passwd2.val() ? 'has-error' : 'has-success' )
|
||||
.removeClass( passwd1.val() === passwd2.val() ? 'has-error' : 'has-success' );
|
||||
return;
|
||||
}
|
||||
else {
|
||||
nomatch.css("display","none");
|
||||
$(document).ready(function() {
|
||||
doCallback = function() {
|
||||
$('#formCreateAccountWrapper').css("display", "none");// to clear the previous option
|
||||
$('#loadingAjaxCallback').css("display", "block");
|
||||
$.ajax({
|
||||
url : "${createAccount}",
|
||||
type : 'POST',
|
||||
datatype : 'json',
|
||||
data : {
|
||||
email : $("#email").val(),
|
||||
firstname : $("#firstname").val(),
|
||||
lastname : $("#lastname").val(),
|
||||
password : $("#password").val(),
|
||||
repassword : $("#repassword").val()
|
||||
},
|
||||
success : function(data) {
|
||||
$('#loadingAjaxCallback').css("display", "none");
|
||||
if (data == "OK") {
|
||||
$('#successDiv').css("display", "block");
|
||||
} else {
|
||||
$('#errorDiv').css("display", "block");
|
||||
$('#errorLabel').text(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var shortpwd = $('#labelPasswordTooShort');
|
||||
|
||||
if (passwd1.val().length > 0 && passwd1.val().length < 8) {
|
||||
shortpwd.css("display","block");
|
||||
shortpwd.css("color","red");
|
||||
labelPwd1.addClass(passwd1.val().length < 8 ? 'has-error' : 'has-success' )
|
||||
.removeClass(passwd1.val().length < 8 ? 'has-error' : 'has-success' );
|
||||
labelPwd2.addClass(passwd2.val().length < 8 ? 'has-error' : 'has-success' )
|
||||
.removeClass(passwd2.val().length < 8 ? 'has-error' : 'has-success' );
|
||||
return;
|
||||
}
|
||||
else {
|
||||
shortpwd.css("display","none");
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
$( "#country" ).change(function() {
|
||||
$.ajax({
|
||||
url: "${findState}" ,
|
||||
type: 'POST',
|
||||
datatype:'json',
|
||||
data: {
|
||||
countryName: $("#country").val()
|
||||
},
|
||||
success: function(data){
|
||||
var content= JSON.parse(data);
|
||||
$('#state').html('');// to clear the previous option
|
||||
$.each(content, function(i, state) {
|
||||
$('#state').append($('<option>').text(state.name).attr('value', state.stateId));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<b>Change the Country State Change By Ajax</b> <br><br>
|
||||
Country:
|
||||
<select id="country" name="country">
|
||||
<option value="select">Select Country</option>
|
||||
<option value="india">India</option>
|
||||
<option value="usa">USA</option>
|
||||
</select>
|
||||
<div id="errorDiv" style="display: none;" class="alert alert-error">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<h1>Oh snap! You got an error</h1>
|
||||
<label id="errorLabel"></label> <br> <br /> If you believe this
|
||||
requires support please go to <a
|
||||
href="http://www.d4science.org/contact-us" target="_blank">http://www.d4science.org/contact-us</a>
|
||||
to ask for D4Science Help Desk support. <br> <br />
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
State:
|
||||
<select id="state" name="state">
|
||||
</select>
|
||||
<h1>
|
||||
Hello
|
||||
<c:out escapeXml="true" value="${invitedUser.firstName}" />!<br>
|
||||
</h1>
|
||||
|
||||
<p class="lead">
|
||||
You have recently received an invitation from
|
||||
<c:out escapeXml="true" value="${inviteInstance.senderFullName}" />
|
||||
to join the <a
|
||||
href="/web<c:out escapeXml="true" value="${vreFriendlyURL}" />"
|
||||
target="_blank"><c:out escapeXml="true" value="${vreName}" /></a>
|
||||
Virtual Research Environment.
|
||||
<c:choose>
|
||||
<c:when test="${empty invitedUser}">
|
||||
<br />
|
||||
<span style="font-style: italic;">Please note</span>: the invite is valid for your email <a
|
||||
href="mailto:<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />">
|
||||
<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />
|
||||
</a> only. To accept the invite, please fill in the information below:
|
||||
<div id="successDiv" style="display: none;" class="alert alert-success">
|
||||
<h1>Well done!</h1>
|
||||
Your account has been successfully created! You will now be asked to enter sign in on this
|
||||
portal using your yet created account. Please, click on the button below to continue.
|
||||
<%
|
||||
String acceptInviteURL = request.getAttribute("landingPage") + "/explore?" + InvitesManager.SITEID_ATTR
|
||||
+ "=" + request.getAttribute("groupId");
|
||||
%>
|
||||
<p style="margin-top: 20px;">
|
||||
<button class="btn btn-large"
|
||||
onclick="window.location.href='<%=acceptInviteURL%>'" type="button">
|
||||
Continue accept invite on
|
||||
<c:out escapeXml="true" value="${vreName}" />
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
<div id="formCreateAccountWrapper">
|
||||
<h1>
|
||||
Hello
|
||||
<c:out escapeXml="true" value="${invitedUser.firstName}" />
|
||||
!<br>
|
||||
</h1>
|
||||
<p class="lead">
|
||||
You have recently received an invitation from
|
||||
<c:out escapeXml="true" value="${inviteInstance.senderFullName}" />
|
||||
to join the <a
|
||||
href="/web<c:out escapeXml="true" value="${vreFriendlyURL}" />"
|
||||
target="_blank"><c:out escapeXml="true" value="${vreName}" /></a>
|
||||
Virtual Research Environment. <img id="loadingAjaxCallback"
|
||||
style="display: none;"
|
||||
src="<%=renderRequest.getContextPath()%>/images/loader.gif" />
|
||||
<c:choose>
|
||||
<c:when test="${empty invitedUser}">
|
||||
<br />
|
||||
<span style="font-style: italic;">Please note</span>: the invite is valid for your email <a
|
||||
href="mailto:<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />">
|
||||
<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />
|
||||
</a> only. To accept the invite, please fill in the information below:
|
||||
<br />
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<fieldset>
|
||||
<label>Email (Not editable)</label> <input type="text" name="email"
|
||||
value="${inviteInstance.invitedEmail}" readonly style="color: #999;"/>
|
||||
<label id="labelFirstName">First Name (Required)</label>
|
||||
<input type="text" id="firstname" />
|
||||
<label id="labelLastName">Last Name (Required)</label>
|
||||
<input type="text" id="lastname" />
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<fieldset>
|
||||
<label id="labelPwd1">Password</label>
|
||||
<input type="password" id="password" />
|
||||
<label id="labelPwd2">Confirm Password</label>
|
||||
<input type="password" id="repassword"/>
|
||||
<label style="display: none" id="labelPasswordDontMatch">Passwords don't match</label>
|
||||
<label style="display: none" id="labelPasswordTooShort">Passwords must be at least 8 chars length</label>
|
||||
<div style="margin-top: 20px;">
|
||||
<button class="btn-primary btn-large" type="button" id="createAccountButton">Continue</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<fieldset>
|
||||
<label>Email (Not editable)</label> <input type="text"
|
||||
name="email" value="${inviteInstance.invitedEmail}" readonly
|
||||
id="email" style="color: #999;" /> <label id="labelFirstName">First
|
||||
Name (Required)</label> <input type="text" id="firstname" /> <label
|
||||
id="labelLastName">Last Name (Required)</label> <input
|
||||
type="text" id="lastname" />
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<fieldset>
|
||||
<label id="labelPwd1">Password</label> <input type="password"
|
||||
id="password" /> <label id="labelPwd2">Confirm
|
||||
Password</label> <input type="password" id="repassword" /> <label
|
||||
style="display: none" id="labelPasswordDontMatch">Passwords
|
||||
don't match</label> <label style="display: none"
|
||||
id="labelPasswordTooShort">Password must be at least 8
|
||||
chars length</label>
|
||||
<div style="margin-top: 20px;">
|
||||
<button class="btn-primary btn-large" type="button"
|
||||
id="createAccountButton">Continue</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
This invite is valid for your email <a
|
||||
href="mailto:<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />">
|
||||
<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />
|
||||
</a> only, you will be asked to enter your password associated to it on this portal.
|
||||
href="mailto:<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />">
|
||||
<c:out escapeXml="true" value="${inviteInstance.invitedEmail}" />
|
||||
</a> only, you will be asked to enter your password associated to it on this portal.
|
||||
|
||||
<%
|
||||
String exploreURL = request.getAttribute("landingPage") + "/explore?" + InvitesManager.SITEID_ATTR
|
||||
+ "=" + request.getAttribute("groupId");
|
||||
%>
|
||||
<p class="lead">
|
||||
<button class="btn btn-large btn-primary"
|
||||
onclick="window.location.href='<%=exploreURL%>'" type="button">
|
||||
Accept invite on
|
||||
<c:out escapeXml="true" value="${vreName}" />
|
||||
</button>
|
||||
</p>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<c:out escapeXml="true" value="${inviteInstance} " />
|
||||
String exploreURL = request.getAttribute("landingPage") + "/explore?" + InvitesManager.SITEID_ATTR
|
||||
+ "=" + request.getAttribute("groupId");
|
||||
%>
|
||||
<p class="lead">
|
||||
<button class="btn btn-large btn-primary"
|
||||
onclick="window.location.href='<%=exploreURL%>'" type="button">
|
||||
Accept invite on
|
||||
<c:out escapeXml="true" value="${vreName}" />
|
||||
</button>
|
||||
</p>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</p>
|
||||
</div>
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,61 @@
|
|||
$(document).ready(function(){
|
||||
$( "#createAccountButton" ).click(function() {
|
||||
var firstnameBox = $.trim( $('#firstname').val() )
|
||||
if (firstnameBox == "") {
|
||||
$('#labelFirstName').css("color","red");
|
||||
$('#labelFirstName').text("First Name (This field is required)");
|
||||
} else {
|
||||
$('#labelFirstName').css("color","#555");
|
||||
$('#labelFirstName').text("First Name (Required)");
|
||||
}
|
||||
var lastnameBox = $.trim( $('#lastname').val() )
|
||||
if (lastnameBox == "") {
|
||||
$('#labelLastName').css("color","red");
|
||||
$('#labelLastName').text("Last Name (This field is required)");
|
||||
} else {
|
||||
$('#labelLastName').css("color","#555");
|
||||
$('#labelLastName').text("Last Name (Required)");
|
||||
}
|
||||
|
||||
var passwd1 = $('#password');
|
||||
var labelPwd1 = $('#labelPwd1');
|
||||
var passwd2 = $('#repassword');
|
||||
var labelPwd2 = $('#labelPwd2');
|
||||
|
||||
labelPwd1.addClass( passwd1.val().length === 0 ? 'has-error' : 'has-success' );
|
||||
labelPwd2.addClass( passwd2.val().length === 0 ? 'has-error' : 'has-success' );
|
||||
|
||||
var nomatch = $('#labelPasswordDontMatch');
|
||||
|
||||
if (passwd1.val() !== passwd2.val()) {
|
||||
nomatch.css("display","block");
|
||||
nomatch.css("color","red");
|
||||
labelPwd1.addClass( passwd1.val() !== passwd2.val() ? 'has-error' : 'has-success' )
|
||||
.removeClass( passwd1.val() === passwd2.val() ? 'has-error' : 'has-success' );
|
||||
labelPwd2.addClass( passwd1.val() !== passwd2.val() ? 'has-error' : 'has-success' )
|
||||
.removeClass( passwd1.val() === passwd2.val() ? 'has-error' : 'has-success' );
|
||||
}
|
||||
else {
|
||||
nomatch.css("display","none");
|
||||
}
|
||||
|
||||
var shortpwd = $('#labelPasswordTooShort');
|
||||
|
||||
if (passwd1.val().length > 0 && passwd1.val().length < 8) {
|
||||
shortpwd.css("display","block");
|
||||
shortpwd.css("color","red");
|
||||
labelPwd1.addClass(passwd1.val().length < 8 ? 'has-error' : 'has-success' )
|
||||
.removeClass(passwd1.val().length < 8 ? 'has-error' : 'has-success' );
|
||||
labelPwd2.addClass(passwd2.val().length < 8 ? 'has-error' : 'has-success' )
|
||||
.removeClass(passwd2.val().length < 8 ? 'has-error' : 'has-success' );
|
||||
}
|
||||
else {
|
||||
shortpwd.css("display","none");
|
||||
}
|
||||
|
||||
if (passwd1.val() == passwd2.val() && passwd1.val().length >= 8 && lastnameBox != "" && firstnameBox != "") {
|
||||
doCallback();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue