本文整理匯總了Golang中github.com/QLeelulu/goku/form.NewCharField函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewCharField函數的具體用法?Golang NewCharField怎麽用?Golang NewCharField使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewCharField函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createRegForm
func createRegForm() *form.Form {
key := form.NewCharField("key", "邀請碼", true).
Error("required", "邀請碼必須填寫").Field()
email := form.NewEmailField("email", "Email", true).
Error("invalid", "Email地址錯誤").
Error("required", "Email地址必須填寫").Field()
pwd := form.NewCharField("pwd", "密碼", true).Min(6).Max(30).
Error("required", "密碼必須填寫").
Error("range", "密碼長度必須在{0}到{1}之間").Field()
name := form.NewCharField("name", "昵稱", true).Min(2).Max(15).
Error("required", "昵稱必須填寫").
Error("range", "昵稱長度必須在{0}到{1}之間").Field()
repwd := form.NewCharField("repwd", "確認密碼", true).Min(6).Max(30).
Error("required", "確認密碼必須填寫").
Error("range", "密碼長度必須在{0}到{1}之間").Field()
// add the fields to a form
form := form.NewForm(key, email, name, pwd, repwd)
return form
}
示例2: createResetPasswordForm
func createResetPasswordForm() *form.Form {
newPwd := form.NewCharField("new-pwd", "新密碼", true).Min(6).Max(30).
Error("required", "新密碼必須填寫").
Error("range", "新密碼長度必須在{0}到{1}之間").Field()
newPwd2 := form.NewCharField("new-pwd2", "確認密碼", true).Min(6).Max(30).
Error("required", "確認密碼必須填寫").
Error("range", "確認密碼長度必須在{0}到{1}之間").Field()
form := form.NewForm(newPwd, newPwd2)
return form
}
示例3: CreateLinkSubmitForm
/**
* 鏈接提交表單
*/
func CreateLinkSubmitForm() *form.Form {
title := form.NewCharField("title", "標題", true).Min(8).Max(140).
Error("required", "標題必須填寫").
Error("range", "標題長度必須在{0}到{1}之間").Field()
context := form.NewRegexpField("context", "URL地址", true, `http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?`).
Error("required", "URL地址必須填寫").
Error("invalid", "URL格式不正確").Field()
topics := form.NewCharField("topics", "話題", false).Field()
form := form.NewForm(title, context, topics)
return form
}
示例4: createLoginForm
/**
* form
*/
func createLoginForm() *form.Form {
// defined the field
email := createEmailField()
pwd := form.NewCharField("pwd", "密碼", true).Min(6).Max(30).
Error("required", "密碼必須填寫").
Error("range", "密碼長度必須在{0}到{1}之間").Field()
remeber_me := form.NewCharField("remeber_me", "記住我", false)
// add the fields to a form
form := form.NewForm(email, pwd, remeber_me)
return form
}
示例5: createUpdatePwdForm
// 更新密碼
func createUpdatePwdForm() *form.Form {
oldPwd := form.NewCharField("old-pwd", "原密碼", true).Min(6).Max(30).
Error("required", "原密碼必須填寫").
Error("range", "原密碼長度必須在{0}到{1}之間").Field()
newPwd := form.NewCharField("new-pwd", "新密碼", true).Min(6).Max(30).
Error("required", "新密碼必須填寫").
Error("range", "新密碼長度必須在{0}到{1}之間").Field()
newPwd2 := form.NewCharField("new-pwd2", "確認密碼", true).Min(6).Max(30).
Error("required", "確認密碼必須填寫").
Error("range", "確認密碼長度必須在{0}到{1}之間").Field()
// add the fields to a form
form := form.NewForm(oldPwd, newPwd, newPwd2)
return form
}
示例6: createBaseInfoForm
// 更新基本信息
func createBaseInfoForm() *form.Form {
description := form.NewTextField("description", "自我介紹", false).Max(100).
Error("max-length", "自我介紹的字數不能多於{0}個").Field()
name := form.NewCharField("name", "用戶名", true).Min(2).Max(15).
Error("required", "用戶名必須填寫").
Error("range", "用戶名長度必須在{0}到{1}之間").Field()
// add the fields to a form
form := form.NewForm(description, name)
return form
}
示例7:
ctx.ViewData["uid"] = token.Uid
ctx.ViewData["expires"] = token.Expires_In
}
return ctx.Render("oauthcallback", nil)
}).
/**
* 新浪微博登錄,提交email和昵稱
*/
Post("sinaoauthcallback", func(ctx *goku.HttpContext) goku.ActionResulter {
email := form.NewEmailField("email", "Email", true).
Error("invalid", "Email地址錯誤").
Error("required", "Email地址必須填寫").Field()
name := form.NewCharField("name", "昵稱", true).Min(2).Max(15).
Error("required", "昵稱必須填寫").
Error("range", "昵稱長度必須在{0}到{1}之間").Field()
// add the fields to a form
f := form.NewForm(email, name)
f.FillByRequest(ctx.Request)
errorMsgs := make([]string, 0)
userId := int64(0)
if f.Valid() {
m := f.CleanValues()
// 檢查email地址是否已經注冊
emailExist := models.User_IsEmailExist(m["email"].(string))
userExist := models.User_IsUserExist(m["name"].(string))
if !emailExist && !userExist {
示例8: createNameField
func createNameField() form.Field {
name := form.NewCharField("name", "昵稱", true).Min(2).Max(15).
Error("required", "昵稱必須填寫").
Error("range", "昵稱長度必須在{0}到{1}之間").Field()
return name
}