Registration page Account Verification

Source: Internet
Author: User

1. First use Ajax to pass the value on the page, after the account <input> remember to write on the <span id= "er" ></span>, or will not prompt the account can be used, have been registered

<script type= "Text/javascript" >
function Home () {
Window.location.href= "view/login.jsp";
}
$ (function () {

Account Verification
$ ("#Account"). blur (function () {

var account=$ ("#Account") [0].value;

$.ajax ({
URL: ' Validation.do ',
Data: {
Account:account,
},
Type: "Post",

Success:function (Result) {

if (result.success) {
$ ("#er"). Text ("Account can be registered")
} else {
$ ("#er"). Text ("This account has been registered");
},

});

});
});

$ (). Ready (function () {
Validate form on Commit
var validator = $ ("#regform"). Validate ({
Errorplacement:function (Error, Element) {

$ (Element)
. Closest ("form")
. Find ("label[for=" + element.attr ("id") + "']")
. append (Error);
},
Rules: {
Account: {
Required:true,
Minlength:3,
Maxlength:20
},
Password: {

Required:true,
Minlength:6,
Maxlength:20
},

Enter_the_password_again: {
Equalto: "#Password"
},

phonenumber:{
Digits:true,
Required:true,
Minlength:11,
Maxlength:11
},
},


Messages: {
Account: {
Required: "Please enter your account!" ",
MinLength: "Please enter 3--20 words",
MaxLength: "Please enter 3--20 words"
},
Password: {
Required: "Password cannot be empty",
MinLength: "Please enter 6--20 words",
MaxLength: "Please enter 6--20 words"
},
Enter_the_password_again: {
Equalto: "Two times password input inconsistency"
},
phonenumber:{
Digits: "Only enter Numbers",
Required: "Please enter your phone",
MinLength: "Please enter the correct phone number format",
MaxLength: "Please enter the correct phone number format"
},
}
});

$ (". Cancel"). Click (function () {
Validator.resetform ();
});
});
</script>


<body>
<form method= "POST" id= "RegForm" >

<table align = "center" border= "1" style= "border-collapse:collapse;" >
<tr>
&LT;TD colspan= "2" > Agent registration </td>
</tr>
<tr>
<td> Account:</td>
<td><input type= "text" name= "account" id= "account"/><span id= "er" ></span>
<label for= "Account" ></label>
</td>
</tr>
<tr>
<td> Password:</td>
<td><input type= "text" name= "Password" id= "Password"/>
<label for= "Password" ></label>
</td>
</tr>
<tr>
<td> Please enter the password again:</td>
<td><input type= "text" name= "Enter_the_password_again" id= "Enter_the_password_again"/>
<label for= "Enter_the_password_again" ></label>
</td>
</tr>
<tr>
<td> Common mobile phone number:</td>
<td><input type= "text" name= "PhoneNumber" id= "PhoneNumber"/>
<label for= "PhoneNumber" ></label>
</td>
</tr>
<tr>
<td> real name:</td>
<td><input type= "text" name= "Realname"/></td>
</tr>

<tr>
<td> ID Number:</td>
<td><input type= "text" name= "Idcardnumber"/></td>
</tr>
<tr>
<td> Agent Area:</td>
<td>
<select id= "province" Name= "province" ></select>
<select id= "City" Name= "City" ></select>
<select id= "area" name= "area" ></select>
<script type= "Text/javascript" >
Addressinit (' Province ', ' City ', ' area ');
</script>
</td>
</tr>
<tr>
<td> Company Name:</td>
<td><input type= "text" name= "Nameofcompany"/></td>
</tr>
<tr>
<td> recommended by People id:</td>
<td><input type= "text" name= "referees"/></td>
</tr>
<tr>
<td> Agent Avatar:</td>
<td><input type= "text" name= "Agencyhead"/></td>
</tr>

<tr>
<td> Corporate photo (handheld ID):</td>
<td><input type= "text" name= "Photoagencyasalegalperson"/></td>
</tr>
<tr>
<td> Business License:</td>
<td><input type= "text" name= "Thebusinesslicense"/></td>
</tr>

<tr>
<td> Business License Copy:</td>
<td><input type= "text" name= "Duplicateofbusinesslicense"/></td>
</tr>
<tr>
<td> Bank account Opening permit:</td>
<td><input type= "text" name= "Thebankopensanaccountlicence"/></td>
</tr>
<tr>
<td> Parent-Agent Id:</td>
<td><input type= "text" name= "Pid"/></td>
</tr>
</tr>
<tr>
<td> please fill in the Secret insurance:</td>
</tr>
<tr>
A:</td> of <td> secret protection
<td>
<select name= "Encrypted_problem_one" >
<option value = "1" > What's your father's name? </option>
<option value = "2" > What's your mother's name? </option>
<option value= "3" > What is your spouse's name? </option>
</select>
</td>
</tr>
<tr>
<td> Secret Answer:</td>
<td><input type= "text" name= "Encrypted_answers_one"/></td>
</tr> <tr>
<td> Secret protection question two:</td>
<td>
<select name= "Encrypted_problem_two" >
<option value = "1" > What's your father's name? </option>
<option value = "2" > What's your mother's name? </option>
<option value= "3" > What is your spouse's name? </option>
</select>
</td>
</tr>
<tr>
<td> Secret Answer:</td>
<td><input type= "text" name= "Encrypted_answers_two"/></td>
</tr>
<tr>
<td> Secret protection question three:</td>
<td>
<select name= "Encrypted_problem_three" >
<option value = "1" > What's your father's name? </option>
<option value = "2" > What's your mother's name? </option>
<option value= "3" > What is your spouse's name? </option>
</select>
</td>
</tr>
<tr>
<td> Secret Answer:</td>
<td><input type= "text" name= "Encrypted_answers_three"/></td>
</tr>
<tr>
&LT;TD class= "Tdstyle" colspan= "2" >
<a href= "javascript:void (0);" class= "Easyui-linkbutton" onclick= "login (); > Registration </a>
<a href= "javascript:void (0);" class= "Easyui-linkbutton" onclick= "Home (); > Back to login </a>
</td>
</tr>
</table>
</form>
</body>

2, using AJAX to pass the value to the validated controller, the annotations are to be played.

Import Java.util.HashMap;
Import Java.util.Map;

Import Javax.annotation.Resource;

Import Org.springframework.stereotype.Controller;
Import org.springframework.web.bind.annotation.RequestMapping;
Import Org.springframework.web.bind.annotation.ResponseBody;

Import Com.maicor.service.ValidationService;

@Controller ("Validationcontroller")
public class Validationcontroller {

@Resource
Validationservice Validationservice;

@RequestMapping (value= "Validation")
@ResponseBody
Public map<string, object> validation (String account) throws Exception {

Map<string, object> result=validationservice.add (account);


return result;
}
}

3, then the controller's value is then passed to the validated service


Import Java.util.HashMap;
Import Java.util.Map;

Import Javax.annotation.Resource;

Import Org.apache.commons.collections.map.HashedMap;
Import org.springframework.beans.factory.annotation.Autowired;
Import Org.springframework.jdbc.core.JdbcTemplate;
Import Org.springframework.stereotype.Service;
Import org.springframework.transaction.annotation.Transactional;

Import Com.maicor.dao.ValidationDao;


@Service ("Validationservice")
public class Validationservice {

@Resource
Private Validationdao Validationdao;

Public map<string, object> Add (String accounts) throws Exception {//Find account to be judged
Map<string, object> map=new hashmap<string, object> ();
try {
if (Validationdao.info (account) >0) {

Map.put ("Success", false);
}else{
Map.put ("Success", true);
}

} catch (Exception e) {
E.printstacktrace ();
}

return map;

}

}

4. Also write a verification of the Dao,dao inside the JDBC Connection database


@Repository ("Validationdao")
public class Validationdao {
@Autowired
Private JdbcTemplate JdbcTemplate;


Search for the account entered is empty, and return the search accounts object
public int info (String account) throws exception{

String sql= "SELECT COUNT (*) from agency where account=?";

int A=jdbctemplate.queryforint (sql,account);

return A;
}
}

Registration page Account Verification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.