Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form Validation] match not working with id #2939

Open
pengham opened this issue Nov 20, 2023 · 2 comments
Open

[Form Validation] match not working with id #2939

pengham opened this issue Nov 20, 2023 · 2 comments
Assignees
Labels
tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build type/feat Any feature requests or improvements type/usage Any support issues asking for help
Milestone

Comments

@pengham
Copy link

pengham commented Nov 20, 2023

I just update to 2.9.3 and found out that match function of form validation is not working like previous version which I used.

HTML:

<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="fomantic/semantic.min.css?v=2.9.3">
	<script type="text/javascript" src="scripts/jquery-3.7.1.min.js"></script>
	<script type="text/javascript" src="fomantic/semantic.js?v=2.9.3"></script>
	<script src="match.js?<?php echo time(); ?>"></script>
</head>
<body>
	<div id="ChangePasswordForm" class="ui form attached fluid segment">
		<div class="ui basic segment">
			<div class="two fields">
				<div id="NewPassword1" class="field">
					<div class="ui left icon input">
						<i class="lock icon"></i>
						<input type="text" placeholder="New Password" id="NewPassword" maxlength="32" value="">
					</div>
				</div>
				<div id="NewPassword2" class="field">
					<div class="ui left icon input">
						<i class="lock icon"></i>
						<input type="text" placeholder="Confirm New Password" id="ConfirmNewPassword" maxlength="32" value="">
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>

Javascript:

$(document).ready(function() {
	var ChangePasswordValidationRules = {
		NewPassword1: {
			identifier: 'NewPassword',
			rules: [{
				type: 'empty',
				prompt: 'Please enter a password'
			}, {
				type: 'minLength[8]',
				prompt: 'Your password must be at least {ruleValue} characters'
			}, {
				type: 'maxLength[32]',
				prompt: 'Your password cannot be longer than {ruleValue} characters'
			}]
		},
		NewPassword2: {
			identifier: 'ConfirmNewPassword',
			rules: [{
				type: 'match[NewPassword]',
				prompt : 'Both passwords do not match'
			}]
		}
	};

	$('#ChangePasswordForm').form({
		fields: ChangePasswordValidationRules,
		inline: true,
		on: 'change',
		onSuccess: function() {
			return false;
		}
	});
});

Expected result:
By right, when textbox with id=NewPassword and id=ConfirmNewPassword have same value, match will not prompt error.

Actual result:
Match prompt error

@pengham pengham added state/awaiting-investigation Anything which needs more investigation state/awaiting-triage Any issues or pull requests which haven't yet been triaged type/bug Any issue which is a bug or PR which fixes a bug labels Nov 20, 2023
@lubber-de lubber-de removed the state/awaiting-triage Any issues or pull requests which haven't yet been triaged label Nov 20, 2023
@lubber-de lubber-de self-assigned this Nov 20, 2023
@lubber-de
Copy link
Member

The validation expects a name property to be present to each form field (ever since we forked from SUI)
I now supported using ids only by #2944
See https://jsfiddle.net/lubber/10yhpnk4/5/

In the meantime / as a workaround, add "name" properties to your input fields as you would do with usual form elements
https://jsfiddle.net/lubber/10yhpnk4/4/

@lubber-de lubber-de added type/feat Any feature requests or improvements type/usage Any support issues asking for help state/has-pr An issue which has a related PR open and removed type/bug Any issue which is a bug or PR which fixes a bug state/awaiting-investigation Anything which needs more investigation labels Nov 24, 2023
@lubber-de lubber-de added this to the 2.9.4 milestone Nov 24, 2023
@pengham
Copy link
Author

pengham commented Nov 25, 2023

Thank you for your attention on this. Hope 2.9.4 will release soon.

@lubber-de lubber-de added tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build and removed state/has-pr An issue which has a related PR open labels Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build type/feat Any feature requests or improvements type/usage Any support issues asking for help
Projects
None yet
Development

No branches or pull requests

2 participants