Commit aace1cf4 authored by roadscape's avatar roadscape
Browse files

update title validation

parent bebb4793
...@@ -5,6 +5,7 @@ import * as communityActions from 'app/redux/CommunityReducer'; ...@@ -5,6 +5,7 @@ import * as communityActions from 'app/redux/CommunityReducer';
import tt from 'counterpart'; import tt from 'counterpart';
import { key_utils } from '@steemit/steem-js/lib/auth/ecc'; import { key_utils } from '@steemit/steem-js/lib/auth/ecc';
import LoadingIndicator from 'app/components/elements/LoadingIndicator'; import LoadingIndicator from 'app/components/elements/LoadingIndicator';
import Unicode from 'app/utils/Unicode';
class CreateCommunity extends React.Component { class CreateCommunity extends React.Component {
constructor() { constructor() {
...@@ -132,11 +133,22 @@ class CreateCommunity extends React.Component { ...@@ -132,11 +133,22 @@ class CreateCommunity extends React.Component {
</div> </div>
); );
const submitCreateCommunityFormButton = ( const submitCreateCommunityFormButton = error => (
<input className="button" type="submit" value="Create Community" /> <input
className="button"
type="submit"
value="Create Community"
disabled={!!error}
/>
); );
const hasPass = communityOwnerWifPassword.length > 0; const hasPass = communityOwnerWifPassword.length > 0;
let formError = null;
const rx = new RegExp('^[' + Unicode.L + ']');
if (!rx.test(communityTitle) && (communityTitle || hasPass))
formError = 'Must start with a letter.';
const form = ( const form = (
<form className="community--form" onSubmit={handleCommunitySubmit}> <form className="community--form" onSubmit={handleCommunitySubmit}>
<div>{tt('g.community_create')}</div> <div>{tt('g.community_create')}</div>
...@@ -145,13 +157,14 @@ class CreateCommunity extends React.Component { ...@@ -145,13 +157,14 @@ class CreateCommunity extends React.Component {
<input <input
id="community_title" id="community_title"
type="text" type="text"
minLength="4" minLength="3"
maxLength="30" maxLength="20"
onChange={handleCommunityTitleInput} onChange={handleCommunityTitleInput}
value={communityTitle} value={communityTitle}
required required
/> />
</label> </label>
{formError && <span className="error">{formError}</span>}
<label> <label>
{tt('g.community_description')} {tt('g.community_description')}
<input <input
...@@ -164,7 +177,7 @@ class CreateCommunity extends React.Component { ...@@ -164,7 +177,7 @@ class CreateCommunity extends React.Component {
</label> </label>
{!hasPass && generateCommunityCredentialsButton} {!hasPass && generateCommunityCredentialsButton}
{hasPass && credentialsPane} {hasPass && credentialsPane}
{hasPass && submitCreateCommunityFormButton} {hasPass && submitCreateCommunityFormButton(formError)}
</form> </form>
); );
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment