umesh.balasu
Posts: 0
Joined: Thu Mar 29, 2012 1:31 pm

Input field validation

I want to be able to use the jQuery validation plugin to validate form fields. Looking through the jQuery validation plugin documentation it requires form tags and special attributes added to the input fields. Has anyone been able to successfully use the validation plugin? If not what are my other validation options. I want to be able to validate my input fields before invoking a service.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Input field validation

There are a number blog posts, articles on jQuery Mobile validation: https://www.google.com/#hl=en&sclient...

I haven't tried them. You can also just get the value of a field with JavaScript and validate its value before invoking a service. You could show the message in an alert window or update a label and show the error message next to the field. Hope this helps.

Louis Adekoya
Posts: 0
Joined: Sun Nov 17, 2013 10:51 pm

Input field validation

Could you please give a quick example of "You can also just get the value of a field with JavaScript and validate its value before invoking a service. "

I have tried the following but it doesn't seem to work - not sure why. I'm new to JS and coding in general, but I have based the following on some examples I've seen.

var vFirstname = Appery(“txtFirstnameReg”).val();

if (vFirstname==null || vFirstname=="")

{

alert("First name must be filled out");

}

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

Input field validation

Hello,

It looks like there is some problem with quotes Appery(“txtFirstnameReg”). Please try to replace quotes with next one "".

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Input field validation

You should check the value that you get in the first line and then see if the if-statement is ever true.

Louis Adekoya
Posts: 0
Joined: Sun Nov 17, 2013 10:51 pm

Input field validation

Thanks both.

Igor, my untrained eye can't see anything wrong with the quotes but you were right. I copied the quotes instead of typing them and it worked. Can I ask what exactly is wrong with the quotes I originally used? Just so I know for next time. Thanks.

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

Input field validation

Hello! There were quotes with a wrong format. You had this one “ ”, but it should be " " .

Louis Adekoya
Posts: 0
Joined: Sun Nov 17, 2013 10:51 pm

Input field validation

Thank you Maryna, I finally figured it out once I put on my glasses :-)

Return to “Issues”