Validation problem
Validation problem
Hi,
I'm trying to validate a form with on submit if statement, unfortunately this code only pops up platenum label or motornum label depending on which is filled, but if both are not filled, it only shows one.
What's wrong with this code?
- // plate number validation on submit
- var formclicked=0;
- $('#reg_addcar').submit(function()
- {
- formclicked=1;
- //validates platenum
- if ($('#motornum').val()==='')
- {
- $('#vmotornum').show().text('This field is required');
- return false;
- }
-
- if ($('#platenum').val() == '')
- {
- $('#vplatenum').show().text('This field is required');
- return false;
- }
-
- //validates if canproceed is false
- if (canproceed == 'false')
- {
- if ($('#vplatenum').text()==='Plate number already exists')
- {
- $('#vplatenum').text('Plate number already exists');
- $('#vplatenum').show();
- }
- return false;
- }
-
- });