Fix problem when user want to edit a line, and see the msg 'The name is invalid'

This commit is contained in:
Olivier PEREZ 2015-03-29 16:02:48 +02:00
parent eb4b40d1d6
commit b298c61869
3 changed files with 8 additions and 7 deletions

View File

@ -16,15 +16,16 @@
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
*/
$(document).ready(function() {
$(document).ready(function () {
$("#poll_form").submit(function( event ) {
$(".check-name").click(function (event) {
var name = $("#name").val();
var regexContent = $("#parameter_name_regex").text().split("/");
var regex = new RegExp(regexContent[1], regexContent[2]);
if (name.length == 0 || !regex.test(name)) {
event.preventDefault();
var newMessage = $("#nameErrorMessage").clone();
var newMessage = $("#nameErrorMessage").clone();
$("#message-container").empty();
$("#message-container").append(newMessage);
newMessage.removeClass("hidden");

View File

@ -69,7 +69,7 @@
</ul>
</td>
{/foreach}
<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="save" value="{$vote->id|html}" title="{__('Poll results\\Save the choices')} {$vote->name|html}">{__('Generic\\Save')}</button></td>
<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs check-name" name="save" value="{$vote->id|html}" title="{__('Poll results\\Save the choices')} {$vote->name|html}">{__('Generic\\Save')}</button></td>
{else}
{* Voted line *}
@ -140,7 +140,7 @@
</ul>
</td>
{/foreach}
<td><button type="submit" class="btn btn-success btn-md" name="save" title="{__('Poll results\\Save the choices')}">{__('Generic\\Save')}</button></td>
<td><button type="submit" class="btn btn-success btn-md check-name" name="save" title="{__('Poll results\\Save the choices')}">{__('Generic\\Save')}</button></td>
</tr>
{/if}

View File

@ -115,7 +115,7 @@
</ul>
</td>
{/foreach}
<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="save" value="{$vote->id|html}" title="{__('Poll results\\Save the choices')} {$vote->name|html}">{__('Generic\\Save')}</button></td>
<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs check-name" name="save" value="{$vote->id|html}" title="{__('Poll results\\Save the choices')} {$vote->name|html}">{__('Generic\\Save')}</button></td>
{else}
{* Voted line *}
@ -190,7 +190,7 @@
{$i = $i+1}
{/foreach}
{/foreach}
<td><button type="submit" class="btn btn-success btn-md" name="save" title="{__('Poll results\\Save the choices')}">{__('Generic\\Save')}</button></td>
<td><button type="submit" class="btn btn-success btn-md check-name" name="save" title="{__('Poll results\\Save the choices')}">{__('Generic\\Save')}</button></td>
</tr>
{/if}