John-Paul Sliva
Posts: 0
Joined: Tue Mar 18, 2014 6:04 pm

Email Validation using Request JavaScript

Can't get the, Request JavaScript , to filter email addresses entered in an, email input component. I want the email to fail if the if statement is false, then an alert will show.

JavaScript below

if (/\w+([.-]?\w+)*@bard.edu$/.test.value);
return value;

HELP?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Email Validation using Request JavaScript

Hello!

Try /\w+([.-]?\w+)*@bard.edu$/.test(value)

value should be in brackets.

John-Paul Sliva
Posts: 0
Joined: Tue Mar 18, 2014 6:04 pm

Email Validation using Request JavaScript

NO LUCK.

Below is what I am doing:

Enter Email and Password: clicking sign up
Image

Connecting inputs to request Username & Password
Image

***NEED JavaScript to stop any emails from entering my database that do not end with (@bard.edu). ????
Image

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Email Validation using Request JavaScript

Hi John,

You should validate your form before you invoke the service.

So for "click" event on your button you should set type "JavaScript" and do the form validation in this JS.

If it passed, invoke your service with this JS code:
pre
serviceName.execute();
/pre

John-Paul Sliva
Posts: 0
Joined: Tue Mar 18, 2014 6:04 pm

Email Validation using Request JavaScript

Not sure if my JS is right?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Email Validation using Request JavaScript

Hi John.

Yes, code is correct.

John-Paul Sliva
Posts: 0
Joined: Tue Mar 18, 2014 6:04 pm

Email Validation using Request JavaScript

I am just not very good at JavaScript,

here is my latest attempt to filter emails that do not end with @bard.edu

Image

Any advice?

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Email Validation using Request JavaScript

Hard coded value "username" in your code should be replaced with your real username value:

pre
code
...

if(/\w+([.-]?\w+)*@bard.edu$/.test("username"))

...
/code
/pre

Return to “Issues”