JavaScript help: abort submission if all fields aren't entered
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 11:01 AM
I cribbed this section of JS, but it only puts up an alert message, while still submitting an empty form. How do I add an abort action to this?
if(user == '' || user == 'undefined' || user == 'null' || desc == 'null' || desc == '' || desc == 'undefined'|| contact == 'null' | contact == ' ' || contact == 'undefined'){
alert('Please enter your name, contact information, and a description of your issue before submitting.');
return;
}
I've tried the following without success. What am I doing wrong?
if(user == '' || user == 'undefined' || user == 'null' || desc == 'null' || desc == '' || desc == 'undefined'|| contact == 'null' | contact == ' ' || contact == 'undefined'){
alert('Please enter your name, contact information, and a description of your issue before submitting.');
return false;
}
if(user == '' || user == 'undefined' || user == 'null' || desc == 'null' || desc == '' || desc == 'undefined'|| contact == 'null' | contact == ' ' || contact == 'undefined'){
alert('Please enter your name, contact information, and a description of your issue before submitting.');
g_form.submitted = false;
return false;
}
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 11:04 AM
@JP-ODU Please try the following and see if it works.
if(user == '' || user == 'undefined' || user == 'null' || desc == 'null' || desc == '' || desc == 'undefined'|| contact == 'null' || contact == ' ' || contact == 'undefined'){
alert('Please enter your name, contact information, and a description of your issue before submitting.');
return false;
}