djorg83 / react-bootstrap-sweetalert

A React implementation of SweetAlert

Home Page:https://djorg83.github.io/react-bootstrap-sweetalert/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inputType="email" not supported

asonni opened this issue · comments

Hi,

I've noticed that inputType="email" not working correct the input accept a none valid email if required ={true}.
Any suggestions how can I fix this?

Thanks

I'll be glad to provide support for this. Can you please provide an example, the expected outcome, and the actual outcome? Thanks.

When I added

<SweetAlert input inputType="email" validationMsg="Please enter your email address" ... />

I got the validation message if I didn't enter anything, but if I enter a non valid email the SweetAlert accept the value.

I suggest to add new property something like this validationEmailMsg="You must provide a valid email address"

You can use this Regex for validation an email

const reEmail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

Thanks

I published version 4.4 with support for this. I'm also exposing a new prop validationRegex if anyone needs to override the regex used.

<SweetAlert 
	 input
         inputType="email" 
         validationMsg="Must be a valid email!"
	 title="Enter your email!" 
	 onConfirm={this.hideAlert} 
> 
 	Email is required
 </SweetAlert>

I just published 4.4.1 and changed the default validationMsg to 'Please enter a valid email!' for inputType of 'email'

It works thank you very much 👍