Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-smf-web
Commits
51240889
Commit
51240889
authored
3 years ago
by
Sakthivel G
Browse files
Options
Download
Patches
Plain Diff
refactor: add invalid error message for email field
parent
4e4cc23b
master
accept_file_type
cards-value-changes
delete-form
delete-user
form-issue
inspector-model
label-change
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
public/css/main.css
+5
-0
public/css/main.css
src/components/form/fields/Input.js
+51
-14
src/components/form/fields/Input.js
with
56 additions
and
14 deletions
+56
-14
public/css/main.css
+
5
−
0
View file @
51240889
...
@@ -2344,6 +2344,11 @@ div.tooltip {
...
@@ -2344,6 +2344,11 @@ div.tooltip {
margin-right
:
3em
;
margin-right
:
3em
;
}
}
.invalid-input
{
font-size
:
0.875rem
;
color
:
red
;
}
/* Admin pannel css starts */
/* Admin pannel css starts */
.admin-pannel
{
.admin-pannel
{
...
...
This diff is collapsed.
Click to expand it.
src/components/form/fields/Input.js
+
51
−
14
View file @
51240889
...
@@ -12,7 +12,9 @@ class Input extends Component {
...
@@ -12,7 +12,9 @@ class Input extends Component {
this
.
state
=
{
this
.
state
=
{
fieldType
:
""
,
fieldType
:
""
,
language
:
"
en
"
,
language
:
"
en
"
,
isInvalid
:
false
,
};
};
this
.
validateEmailInput
=
this
.
validateEmailInput
.
bind
(
this
);
}
}
componentDidMount
()
{
componentDidMount
()
{
...
@@ -34,6 +36,21 @@ class Input extends Component {
...
@@ -34,6 +36,21 @@ class Input extends Component {
}
}
}
}
validateEmailInput
=
(
e
)
=>
{
let
inputData
=
e
.
target
.
value
;
//eslint-disable-next-line
let
allowedFormat
=
/^
\w
+
([\.
-
]?\w
+
)
*@
\w
+
([\.
-
]?\w
+
)
*
(\.\w{2,3})
+$/
;
if
(
inputData
.
match
(
allowedFormat
))
{
this
.
setState
({
isInvalid
:
false
,
});
}
else
{
this
.
setState
({
isInvalid
:
true
,
});
}
};
render
()
{
render
()
{
// console.log(this.props.field.fieldType);
// console.log(this.props.field.fieldType);
// strings.setLanguage(
// strings.setLanguage(
...
@@ -54,20 +71,40 @@ class Input extends Component {
...
@@ -54,20 +71,40 @@ class Input extends Component {
<
/span
>
<
/span
>
)}
)}
<
/label
>
<
/label
>
<
input
{
this
.
props
.
field
.
fieldType
!==
type
=
{
LANG
.
FIELD_TYPES
.
email
.
toLowerCase
()
&&
(
this
.
props
.
field
.
fieldType
===
<
input
LANG
.
FIELD_TYPES
.
numeric
type
=
{
?
"
number
"
this
.
props
.
field
.
fieldType
===
LANG
.
FIELD_TYPES
.
numeric
:
this
.
state
.
fieldType
?
"
number
"
}
:
this
.
state
.
fieldType
id
=
{
"
field-
"
+
this
.
props
.
field
.
order
}
}
name
=
{
"
field_
"
+
this
.
props
.
field
.
order
}
id
=
{
"
field-
"
+
this
.
props
.
field
.
order
}
className
=
"
form-control
"
name
=
{
"
field_
"
+
this
.
props
.
field
.
order
}
placeholder
=
"
Type here
"
className
=
"
form-control
"
autoComplete
=
"
off
"
placeholder
=
"
Type here
"
/>
autoComplete
=
"
off
"
/>
)}
{
this
.
props
.
field
.
fieldType
===
LANG
.
FIELD_TYPES
.
email
.
toLowerCase
()
&&
(
<
div
className
=
""
>
<
input
type
=
"
email
"
id
=
{
"
field-
"
+
this
.
props
.
field
.
order
}
name
=
{
"
field_
"
+
this
.
props
.
field
.
order
}
className
=
"
form-control
"
placeholder
=
"
Type here
"
autoComplete
=
"
off
"
onChange
=
{
this
.
validateEmailInput
}
/
>
{
this
.
state
.
isInvalid
&&
(
<
p
className
=
"
invalid-input
"
>
Invalid
email
!<
/p
>
)}
<
/div
>
)}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
);
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets