# HG changeset patch # User Yader Velasquez # Date 1671235749 21600 # Fri Dec 16 18:09:09 2022 -0600 # Node ID fed5da1379e3909e4ae8e6da4037715707394fd5 # Parent b84c7d8565789bc47e43a13f166eb0c8d1e2c4dc Add js script to func diff --git a/formguard.go b/formguard.go --- a/formguard.go +++ b/formguard.go @@ -1,7 +1,7 @@ package formguard import ( - "errors" + "fmt" "html/template" "strings" @@ -32,7 +32,7 @@ } if f.AntiSpam < FormGuardMinValue { - return errors.New("This operation is forbidden") + return validate.InputErrors{"_global_": []string{"This operation is forbbiden."}} } return nil @@ -41,9 +41,30 @@ // ScriptJS ... func ScriptJS(ids ...string) template.HTML { script := `` - script = strings.Replace(script, "", strings.Join(ids, ","), 1) + var idsList string + for _, id := range ids { + idsList += fmt.Sprintf("'%s',", id) + } + script = strings.Replace(script, "", idsList, 1) return template.HTML(script) }